C#List<string>和string[]之间的相互转换

1.从System.String[]转到List<System.String>

            List<System.String> List = new List<System.String>();
            string[] str={"1","2","3"};
            List = new List<System.String>(str);

2.从List<System.String>转到System.String[]

            List<System.String> List = new List<System.String>();
            List.Add("1");
            List.Add("2");
            List.Add("3");
            System.String[] str = { };
            str = List.ToArray();

3.字符串数组可以,其他有些类型像int数组等等的也是可以的。

posted @ 2012-12-03 12:12  aehyok  阅读(2099)  评论(4编辑  收藏  举报