C#里List很好用。其中一项就是动态数组。
如一下例子:
public int[] abc()
{
List<int> num=new List<int>();
//加一个内容
num.add(1);
//再加一个内容
num.add(2);
//转成数组,返回。
return num.toArray();
}
本文介绍了C#中List作为动态数组的使用方法,并通过一个简单示例展示了如何创建List、添加元素及转换为数组的过程。
C#里List很好用。其中一项就是动态数组。
如一下例子:
public int[] abc()
{
List<int> num=new List<int>();
//加一个内容
num.add(1);
//再加一个内容
num.add(2);
//转成数组,返回。
return num.toArray();
}
479
1365
1582

被折叠的 条评论
为什么被折叠?