Methods for converting between List and arrays in C
- 2020-12-22 17:45:18
- OfStack
This article illustrates the conversion between List and arrays in C#. Share to everybody for everybody reference. The specific analysis is as follows:
1. List transpose array (from List < string > Go to string [])
List<string> listS=new List<string>();
listS.Add("str");
listS.Add("hello");
string[] str=listS.ToArray();
2. Array to List (from string[] to List < string > )
string[] str={"str","string","abc"};
List<string> listS=new List<string>(str);
Hopefully this article has helped you with your C# programming.