首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

麻烦大家告诉一下小弟我如何去获取list<>的长度

2013-12-26 
麻烦大家告诉一下我怎么去获取list的长度Liststring a new Liststring()int i 0while (true){

麻烦大家告诉一下我怎么去获取list<>的长度
   List<string> a = new List<string>();

            int i = 0;
            while (true)
            {
                a.Add(Console.ReadLine());

                string c = a[i];

                if (c == "")
                    break;
                i++;
            }
想问一下,怎么去表示a的长度,我用a.length貌似不能获取
[解决办法]
try this:

List<string> a = new List<string>();

int i = 0;
while (i<10)
{
    a.Add(i.ToString());
    i++;
}
Console.ReadLine(a.Length);

[解决办法]
Count属性
[解决办法]
List<string> a = new List<string>();
string s = "";
while (true)
{
    s = Console.ReadLine();
    if (s == "") break;
    a.Add(s);
}
[解决办法]
a.Count
[解决办法]
a.Count()可以获取 这个是LINQ方式获取--这个是Linq
a.Count也可以获取 这个是集合的长度属性--这个是属性

热点排行