简体   繁体   中英

To remove double quotes in string array

In the below code i have a string array which holds values like "1,2,3" i want to remove the double quotes and display as 1,2,3.pls help me to do this.

string[] Stocks = StockDetails.ToArray();
string s = string.Join(",", Stocks);

If you're having string in this format

string str = "\"1,2,3\"";

..then you can simply remove the double quotation marks using Replace method on string.

str = str.Replace("\"", "");

..this will replace the double quotation from your string, and will return the simple text that is not a double quotes.

More I don't think strings are like this, you're having a look at the actual value of the variable string you're having. When you will use it, it will give you the actual 1, 2, 3 but however, use the above code to remove the quotation .

You can just use string.Replace

var listOfStrings = StockDetails.Select(s => s.Replace("\"", string.Empty))
                                .ToList();

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