Convert string [] to List <string>:
Common browsing and copying code
String [] str = {"1", "2", "3 "};
List <string> list = new List <string> (str );
Convert from List to string []:
Common browsing and copying code
List <string> list = new List <string> ();
String [] str = list. ToArray ();
The Array class implements the Bubble Sorting of elements in the Array. The Sort () method requires that the elements in the array implement the IComparable interface.
For example, System. Int32 and System. String implement the IComparable interface, so the following Array can use Array. Sort ():
Common browsing and copying code
String [] names = {"Lili", "Heicer", "Lucy "};
Array. Sort (names );
Foreach (string name in names)
{
Console. WriteLine (name );
}
If you use a custom class for the array, you must implement the IComparable interface. This excuse defines a method CompareTo ().