My FeedDiscussionsHeadless CMS
New
Sign in
Log inSign up
Learn more about Hashnode Headless CMSHashnode Headless CMS
Collaborate seamlessly with Hashnode Headless CMS for Enterprise.
Upgrade ✨Learn more

Replacing "&" with ""

Zachary Stone's photo
Zachary Stone
·Nov 30, 2017

I created a method that takes in a string and checks for characters that typically doesn't play nice with URLs. All but the "&" char is being removed correctly.

Does anyone know why this is being ignored?

My Method:

   public static string URLify (string deviceName)
        {
            deviceName.Replace("/", "-").Replace("&", "").Replace(" ", "-").Replace("+", "");
            return deviceName;

        }