
C#
L菌体
这个作者很懒,什么都没留下…
展开
-
C#集合的练习
写一个长度为10的集合,要求在里面随机地存放10个数字(0-9) 要求所有数字不重复 ArrayList list = new ArrayList(); Random r = new Random(); //如果写 i<list.Count ,Count表示实际存在的数,实际上集合为0,条件不成立,所以不会执行 for(int i=0;i<10;i++) { i.原创 2021-02-04 16:04:52 · 167 阅读 · 0 评论 -
C#集合的长度问题
using System;using System.Collections;namespace 集合的长度{ class Program { static void Main(string[] args) { ArrayList list = new ArrayList(); list.Add(1); list.Add(2); list.Add(1);原创 2021-02-04 16:04:03 · 2990 阅读 · 1 评论 -
C#集合
using System;using System.Collections;namespace 集合{ class Program { static void Main(string[] args) { //创建集合 (集合:可以添加任意类型的元素,且长度可以任意改变) ArrayList list = new ArrayList(); //添加单个元素 索引从[0]开始原创 2021-02-04 16:03:23 · 66 阅读 · 0 评论 -
C# 里式转换
using System;namespace 里式转换练习{ class Program { static void Main(string[] args) { //创建 人类 学生 老师 野兽 美女 五个对象 //每次调用此程序时, 都随机输出不同人的打招呼 Person[] pers = new Person[6]; //利用随机数原创 2021-02-04 14:39:09 · 102 阅读 · 0 评论 -
C# vs中快速生成get set方法
先选中,然后 Ctrl+R 然后 Ctrl+E原创 2021-02-03 11:13:52 · 5674 阅读 · 0 评论 -
C#继承
using System;namespace 继承{ class Program { static void Main(string[] args) { Student s1 = new Student("张三",14); Console.WriteLine("姓名:"+s1.name+"年龄:"+s1.age ); Console.ReadKey(); }原创 2021-02-03 10:26:13 · 92 阅读 · 0 评论 -
C# params可变参数
using System;namespace params可变参数{ /* params可变参数 将实参列表中跟可变参数数组类型一致的元素都当做数组的元素去处理 params可变参数必须是形参列表中的最后一个元素 */ class Program { static void Main(string[] args) { int[] s = { 3, 4, 5, 1 };原创 2021-01-25 15:20:41 · 71 阅读 · 0 评论 -
C# ref参数
using System;namespace ref参数{ class Program { static void Main(string[] args) { /* ref参数 能够将一个变量带入一个方法中进行改变,改变完成后,再将改变后的值带出方法 要求在方法外必须为其赋值,而方法内可以不赋值 */原创 2021-01-25 12:12:06 · 203 阅读 · 0 评论 -
C#out参数
using System;namespace 参数{ class Program { static void Main(string[] args) { #region out参数的使用1 //out参数侧重于在一个方法中可以返回多个不同类型的值 //写一个方法,求一个数组中的最大值,最小值,总和,平均值 // int[] numbers = { 1,原创 2021-01-25 11:58:02 · 387 阅读 · 0 评论 -
C#枚举
using System;namespace 枚举{ public enum QQState { Online, Offline, Leave, Busy, Qme } public enum Genger { 男, 女 } class Program { static void Main(string[] ar原创 2021-01-20 17:47:58 · 135 阅读 · 0 评论