不定长数组

版权声明:@今年依旧12岁 https://blog.csdn.net/qq_34087199/article/details/89487924

使用泛型List<>转换

List<string> mylist = new List<string>();
            if (Line.Contains(','))
            {
                string[] a = Line.Split(',');
                for(int i=0;i<a.Length;i++)
                {
                    mylist.Add(a[i]);                
                }
            }
            else
            {
                mylist.Add(Line);
            }
string[] unit = mylist.ToArray();
string[] unitStation = new string[]{ };
//这样定义的数组,长度为0;

猜你喜欢

转载自blog.csdn.net/qq_34087199/article/details/89487924