当前位置:编程学习 > C#/ASP.NET >>

麻烦大家告诉一下我怎么去获取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貌似不能获取 --------------------编程问答-------------------- a.Count --------------------编程问答-------------------- 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.Length也可以获取 这个是集合的长度属性--这个是属性 --------------------编程问答-------------------- 楼上正解。。。 --------------------编程问答-------------------- a.Count()可以获取 这个是LINQ方式获取--这个是Linq
a.Count也可以获取 这个是集合的长度属性--这个是属性 --------------------编程问答--------------------
引用 7 楼 h503206 的回复:
楼上正解。。。
啊。。。我写错了。。。。。
补充:.NET技术 ,  C#
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,