[英]String.Replace char to string
I would like to replace the french letter Æ with the asci corresponding AE, but the method does not accept this. 我想用对应的AE代替法文字母Æ,但是该方法不接受。 Is there another way?
还有另一种方法吗?
怎么样:
myString.Replace("Æ", "AE");
代替string.Replace('Æ','AE')
,使用string.Replace("Æ", "AE")
。
This doesn't work? 这行不通吗?
string x = "ÆHELLO";
string y = x.Replace("Æ", "AE");
只需在您的char上调用.ToString()
:
var str = str.Replace('Æ'.ToString(), "AE");
This should work since it is a valid Unicode character - are you sure you are re-assigning the string? 这应该有效,因为它是有效的Unicode字符-您确定要重新分配字符串吗? strings are immutable so this is necessary:
字符串是不可变的,因此这是必需的:
string test = "Æblah";
test = test.Replace("Æ", "AE");//test is now "AEblah"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.