Click here to Skip to main content
15,896,201 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
string value=Testfirst,testlast,testmiddle,Yes,HelpDesk,\"Armed Vasanth,25-05-2012\",Testing,Golbal,\"USD $25,000.00\""

i want format like this Testfirst,testlast,testmiddle,Yes,HelpDesk,Armed Vasanth 25-05-2012,Testing,Golbal,USD $25000.00.
Posted
Updated 16-Jul-12 0:20am
v4
Comments
Nilesh Patil Kolhapur 16-Jul-12 6:03am    
please improve your question

Hi,

why you are reposting again..?? you have already posted similar question which is here.

How to Remove Double quote and comma in a string[^]
 
Share this answer
 
C#
private static void Main(string[] args)
{
    var value = "test1,test2,\"test3\",test4";

    var arr = value.Split(',');
    var result = "";
    for (int i = 0; i < arr.Length; i++)
    {
        var s = arr[i];
        if(s.StartsWith("\"") && s.EndsWith("\""))
        {
                result +=  s.Substring(1, s.Length - 2);
        }
        else
        {
            result += s;
        }
        if (i < arr.Length-1)
            result += ",";
    }

    Console.WriteLine(result);
    Console.Read();
}
 
Share this answer
 
Make an effort to learn about the properties and methods of the System.String[^] class, it is probably the one you will make most use of.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900