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 + "*");
}
Source: http://www.cnblogs.com/eric_ibm/p/list.html
List<int> Turn string:
List<int>: 1,2,3,4,5,6,7 converted to string: "1,2,3,4,5,6,7"
list<int> list= New List<int> () {1, 2, 3, 4, 5, 6, 7};string depaid = string. Join (",", list);
String turn list<int>:
string s = "1, 2, 3"; list<string> list = new List<string> (S.split (new string[] {","}, Stringsplitoptions.removeemptyentries));
list<string> list = new list<string> (S.split (', '));//or
List<string> Turn list<int>
var listOfStrings =(new[]{"4","5","6"}).ToList();
var listOfInts = listOfStrings.Select<string,int>(q =>Convert.ToInt32(q));
List<int> Turn list<string>
list<int> L1 = new list<int> (new int[] {}); list<string> L2 = L1. convertall<string> (x = x.tostring ());
C # string[] arrays and list<string>:
system.string[] str={"str", "String", "abc"}; list<system.string> lists=new list<system.string> (str);
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 ();
Source: http://www.cnblogs.com/chear/archive/2012/12/22/2828956.html
system.string[] strarr={"str", "String", "abc"};
func<string, string[]> func = (str) = =
{
if (str = = null)
str = string. Empty;
Return str. Split (', ');
};
ilist<system.int> ilists = Typeparse.tolistint (func (Strarr));
C # List and string convert each other