This forum has migrated to Microsoft Q&A. Visit Microsoft Q&A to post new questions.
ex)12456,test ,45,45,4563
-> 12456,test
You can do something like :
string sString = "12456,test ,45,45,4563"; string sResult = sString.Substring(0, sString.IndexOf(',', sString.IndexOf(',') + 1)).TrimEnd();
or use LINQ and String.Join():
var result = String.Join(",", "12456,test ,45,45,4563".Split(',').Select(i => i.Trim()).Take(2));