How to add comma separated string into datatable in c#?

后端 未结 4 1918
北荒
北荒 2020-12-21 13:14

Let\'s consider I have two comma separated strings as written below.

string name = \"A,B,C,D\";
string value = \"100,200,300,400\";

So I wa

4条回答
  •  旧巷少年郎
    2020-12-21 14:06

    try this:

      string[] name = "A,B,C,D".Split(',');
               string[] value = "100,200,300,400".Split(',');
                 DataTable tbl = new DataTable();
                 tbl.Columns.Add("name", typeof(string));
                 tbl.Columns.Add("value", typeof(string));
                for( int i=0; i

提交回复
热议问题