-2

I have this code

private string Site;

        public string SiteID
        {
            get {
                if (this.Type == 0)
                {
                    Site.Replace("Æ", "Æ");
                    Site.Replace("Ø", "Ø");
                    Site.Replace("Å", "Å");
                    Site.Replace("æ", "æ");
                    Site.Replace("ø", "ø");
                    Site.Replace("å", "å");
                }

                return Site;
            }
            set { Site = value; }
        }

In my model class. But when it comes to getting a string that looks like this: "LØNX" and I step through it in debugging mode and its exactly the same after. Even though this line:

Site.Replace("Ø", "Ø"); 

should have changed it. Why doesn't it??

tereško
  • 58,060
  • 25
  • 98
  • 150
stibay
  • 1,200
  • 6
  • 23
  • 44

1 Answers1

7

The replace returns the modified string. It does not change the existing one

Site = Site.Replace("Æ", "Æ");
Gridly
  • 938
  • 11
  • 13