-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??

2
  • FYI if you are unaware there is System.Web.HttpUtility.HtmlDecode() Commented Aug 8, 2014 at 12:39
  • @Html.Raw(ViewBag.keywords) Commented Mar 15, 2023 at 12:50

1 Answer 1

7

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

Site = Site.Replace("Æ", "Æ");
Sign up to request clarification or add additional context in comments.

1 Comment

ah thank you! Googled alot even and didnt find that :S

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.