Split comma-separated values

前端 未结 6 576
孤街浪徒
孤街浪徒 2020-12-09 09:05

I am using Visual Studio 2005 and C# 2.0, and I am trying to split a comma-separated string using the string.Split function and a lambda expression as follows:<

6条回答
  •  误落风尘
    2020-12-09 09:34

    .NET 2.0 does not support LINQ - SO thread;
    But you can create a 3.5 project in VS2005 - MSDN thread

    Without lambda support, you'll need to do something like this:

    string s = "a,b, b, c";
    string[] values = s.Split(',');
    for(int i = 0; i < values.Length; i++)
    {
       values[i] = values[i].Trim();
    }
    

提交回复
热议问题