Bartlomiej Lewandowski
Bartlomiej Lewandowski

Reputation: 11190

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?

Upvotes: 1

Views: 15503

Answers (5)

Liron
Liron

Reputation: 2032

This doesn't work?

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

Upvotes: 4

BrokenGlass
BrokenGlass

Reputation: 161002

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"

Upvotes: 2

Eric Mickelsen
Eric Mickelsen

Reputation: 10377

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

Upvotes: 4

Oleks
Oleks

Reputation: 32343

Just call .ToString() on your char:

var str = str.Replace('Æ'.ToString(), "AE");

Upvotes: 3

CodingGorilla
CodingGorilla

Reputation: 19872

How about:

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

Upvotes: 10

Related Questions