简体   繁体   中英

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

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

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