开发者

String.Replace char to string

开发者 https://www.devze.com 2023-02-20 10:10 出处:网络
I would like to 开发者_Go百科replace the french letter Æ with the asci corresponding AE, but the method does not accept this. Is there another way?How about:

I would like to 开发者_Go百科replace the french letter Æ with the asci corresponding AE, but the method does not accept this. Is there another way?


How about:

myString.Replace("Æ", "AE");


Instead of string.Replace('Æ','AE'), use string.Replace("Æ", "AE").


This doesn't work?

string x = "ÆHELLO";
string y = x.Replace("Æ", "AE");


Just call .ToString() on your char:

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? strings are immutable so this is necessary:

string test = "Æblah";
test = test.Replace("Æ", "AE");//test is now "AEblah"
0

精彩评论

暂无评论...
验证码 换一张
取 消