I would like to replace the french letter Æ with the asci corresponding AE, but the method does not accept this. Is there another way?
5 Answers
How about:
myString.Replace("Æ", "AE");
1 Comment
Tom
It should be noted that you make use of double quotes, not single ones. Single ones stand for chars, double ones for strings.
Just call .ToString() on your char:
var str = str.Replace('Æ'.ToString(), "AE");
4 Comments
CodingGorilla
That seems like a long way around to just putting in: "Æ". Am I missing something?
Oleks
@Coding Gorilla, yes you're right. It's easier to use a string constant here :)
CodingGorilla
Ok, I'm one of those dumb US developers that doesn't worry about foreign characters, so I wasn't sure if there was something I didn't know. =)
N Kozlov-Evans
This actually answers the question.Yes, it is easier to replace a string with another, but the question specified 'String.Replace char to string'. It may well be that the char is a const and cannot simply be changed to a string.