Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove double quotes inside a variable?

Tags:

string

c#

.net

Let's say we have variable x with value "hello world" (with quotes)

string x = @"""hello world""";

string y = ???

How to convert x to hello world (without quotes) and assign it to y ?

like image 769
ayman Avatar asked Jan 23 '26 02:01

ayman


1 Answers

You can use string.Trim passing it a double quote. It would remove double quote from start and end of the string. Like.

string y = x.Trim('"');
like image 57
Habib Avatar answered Jan 25 '26 17:01

Habib