语言学多了然后c#数组的写法总是忘,写个博客记下来方便自己也方便他人啦。
int[] arr = new int[5];//可以不赋初始值,默认全部为零
int[] arr = new int[5] {1, 2, 3, 5,4 };//也可以赋初始值。
int[] arr;
arr = new int[5];//当然也可以这样写
在c#中,数组其实是一个对象,所有数组类型的抽象类型都是Array;
语言学多了然后c#数组的写法总是忘,写个博客记下来方便自己也方便他人啦。
int[] arr = new int[5];//可以不赋初始值,默认全部为零
int[] arr = new int[5] {1, 2, 3, 5,4 };//也可以赋初始值。
int[] arr;
arr = new int[5];//当然也可以这样写
在c#中,数组其实是一个对象,所有数组类型的抽象类型都是Array;