小编Ana*_*lia的帖子

有效地分割格式为“ {{},{},...}”的字符串

我有string以下格式。

string instance = "{112,This is the first day 23/12/2009},{132,This is the second day 24/12/2009}"

private void parsestring(string input)
{
    string[] tokens = input.Split(','); // I thought this would split on the , seperating the {}
    foreach (string item in tokens)     // but that doesn't seem to be what it is doing
    {
       Console.WriteLine(item); 
    }
}
Run Code Online (Sandbox Code Playgroud)

我期望的输出应如下所示:

112,This is the first day 23/12/2009
132,This is the second day 24/12/2009
Run Code Online (Sandbox Code Playgroud)

但是目前,我得到以下内容:

{112
This is the first day 23/12/2009
{132 …
Run Code Online (Sandbox Code Playgroud)

c# split string-parsing

4
推荐指数
3
解决办法
106
查看次数

标签 统计

c# ×1

split ×1

string-parsing ×1