简体   繁体   中英

Remove Commas in a string and insert each comma-separated value into a string

How would I do this?

To bring it into some better context, I'm having a value from an XML attribute and I want each individual value to be added to an array of strings and each of those values is separated by commas

Is string.Split what you're after? It's not entirely obvious from your question.

string text = "a,b,c";
string[] bits = text.Split(',');

foreach (string bit in bits)
{
    Console.WriteLine(bit);
}
        string input = Console.ReadLine();
        char splitter = ',' ;
        string[] output = input.Split(splitter);
        foreach (string t in output)
        {
            Console.WriteLine(t);
        }

how are these values stored in the xml? If you know the structure of the xml you can easily extract the info..i din quite get the next part. you want to make a CSV but u also want to store it in an array.but wont the array itself seperate the values?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM