1

我有一个问题,我怎样才能分割字符串并使分割的字符串逐行显示?

细绳:

What is "that" ENUM "No", "Yes", "OK", "Cancel";

我想要数据表:

Name   Type    Comment
"that" ENUM    "No"       // all of them
               "Yes"      // should be
               "OK"       // in the same
               "Cancel"   // cell

一定是有string[] tmpList = tmp.Split(new Char[] { ' ',',', ';' }, StringSplitOptions.RemoveEmptyEntries);然后attributeDEF.Rows.Add(new object[] { tmpList1[1], tmpList1[2], tmpList1[3] + "\n" + tmpList[a]+ "\n"});

有人可以给我一个线索吗?

4

2 回答 2

1

以下代码将为您生成一行:

string tmp = @"What is ""that"" ENUM ""No"", ""Yes"", ""OK"", ""Cancel";

string[] tmpList = tmp.Split(new Char[] { ' ',',', ';' }, StringSplitOptions.RemoveEmptyEntries);

var row = new object[] { tmpList[0], tmpList[3], string.Join("\n", tmpList.Skip(4).ToArray()) };
于 2012-10-29T13:35:51.020 回答
1

如果您询问为最后一个单元格连接字符串,那么这可能是一种选择:

var result = String.Join("\n", tmpList.Skip(4).ToArray());
于 2012-10-29T13:38:04.453 回答