C#数组VS泛型列表 [英] c# array vs generic list
本文介绍了C#数组VS泛型列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我基本上想知道在使用通用的列表,而不是在下面提到的情景数组
i basically want to know the differences or advantages in using a generic list instead of an array in the below mentioned scenario
class Employee
{
private string _empName;
public string EmpName
{
get{ return _empName; }
set{ _empName = value; }
}
}
1. Employee[] emp
2. List<Employee> emp
谁能告诉我的优点或缺点,并且其中一至preFER?
can anyone please tell me the advantages or disadvantages and which one to prefer?
推荐答案
一大区别是,列表&LT;员工&GT;
可扩展(你可以调用添加就可以了)或收缩而员工[]是固定的大小(你可以调用它删除)。因此,员工[]
是强硬与除非必要要求它的工作。
One big difference is that List<Employee>
can be expanded (you can call Add on it) or contracted (you can call Remove on it) whereas Employee[] is fixed in size. Thus, Employee[]
is tougher to work with unless the need calls for it.
这篇关于C#数组VS泛型列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文