假设我们有变量x,其值为"hello world"(带引号)
string x = @"""hello world""";
string y = ???
Run Code Online (Sandbox Code Playgroud)
如何将x转换为hello world(不带引号)并将其分配给y?
您可以使用string.Trim双引号传递它.它将从字符串的开头和结尾删除双引号.喜欢.
string y = x.Trim('"');
Run Code Online (Sandbox Code Playgroud)