1. Go from System. String [] to List <System. String>
System. String [] str = {"str", "string", "abc "};
List <System. String> listS = new List <System. String> (str );
2. Go from List <System. String> to System. String [].
List <System. String> listS = new List <System. String> ();
ListS. Add ("str ");
ListS. Add ("hello ");
System. String [] str = listS. ToArray ();
The test is as follows:
Using System;
Using System. Collections. Generic;
Using System. Linq;
Using System. Text;
Namespace ConsoleApplication1
{
Class Program
{
Static void Main (string [] args)
{
System. String [] sA = {"str", "string1", "sting2", "abc "};
List <System. String> sL = new List <System. String> ();
For (System. Int32 I = 0; I <sA. Length; I ++)
{
Console. WriteLine ("sA [{0}] = {1}", I, sA [I]);
}
SL = new List <System. String> (sA );
SL. Add ("Hello! ");
Foreach (System. String s in sL)
{
Console. WriteLine (s );
}
System. String [] nextString = sL. ToArray ();
Console. WriteLine ("The Length of nextString is {0}", nextString. Length );
Console. Read ();
}
}
}
Result: