1, from system.string[] go to list<system.string>
System.string[] str={"str","String","ABC "}; List<System.String> lists=new list<system.string> (str);
2, transfer 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 ();
Test:
protected voidPage_Load (Objectsender, EventArgs e) {system.string[] SA= {"Str","string1","sting2","ABC" }; List<System.String> SL =NewList<system.string>(); for(System.Int32 i =0; i < sa.length; i++) {Console.WriteLine ("Sa[{0}]={1}", I, sa[i]); } SL=NewList<system.string>(SA); Sl.add ("hello!"); foreach(System.String SinchSL) {Response.Write (s); Response.Write ("<br/>"); //Console.WriteLine (s);} system.string[] Nextstring=Sl.toarray (); //Console.WriteLine ("The Length of Nextstring is {0}", nextstring.length); //Console.read ();Response.Write ("The Length of nextstring is:"+nextstring.length); }
Results:
Reference: http://www.jb51.net/article/32390.htm
Conversion between list〈string〉 and string[] arrays in C #