Original: C # list and string convert each other
List to string, separated by commas
list<string> list = new list<string> ();
List. ADD ("a");
List. ADD ("B");
List. ADD ("C");
MessageBox.Show (list.);
Loadmodel ();
string s = String. Join (",", list. ToArray ());
MessageBox.Show (s);
list<test> list = new list<test> ();
List. ADD (New Test ("1", "a"));
List. ADD (New Test ("2", "B"));
List. ADD (New Test ("", ""));
List. ADD (New Test ("3", "C"));
var a = from O in list select O.test1;
var B = from O in list select O.test2;
string S1 = string. Join (",", A.toarray ());
String s2 = string. Join (",", B.toarray ());
MessageBox.Show (S1 + "\ r \ n" + s2);
Results: 1,2,,3
A,b,,c
String Goto List
Here s the delimiter is not "," but ",", followed by a space
string s = "1, 2, 3";
list<string> list = new List<string> (S.split (new string[] {","}, Stringsplitoptions.removeemptyentries));
foreach (String T in list)
{
MessageBox.Show ("*" + t + "*");
}
Here s the delimiter is ","
string s = "All-in-all";
list<string> list = new list<string> (S.split (', '));
foreach (String T in list)
{
MessageBox.Show ("*" + t + "*");
}
C # List and string convert each other