Loading ...

Strip hyphens from GUID

Who is online?  0 guests and 0 members
home  »  forums   »  asp.net topics   »  getting started / general asp.net   » Strip hyphens from GUID

Strip hyphens from GUID

Posts under the topic: Strip hyphens from GUID

Posted: 12/12/2010

Lurker 100  points  Lurker
  • Joined on: 9/11/2010
  • Posts: 20

Hi,

I have my GUID as 15208bff-0e77-4439-9dfb-0c6de2b5394c . I need to strip (-) hyphens from it. How can I do it ?


Posted: 12/12/2010

Guru 16813  points  Guru
  • Joined on: 4/19/2009
  • Posts: 490
  Answered
using System;

namespace ConsoleApplication1
{
    class MyMain
    {
        public static void Main()
        {
            string guid = Guid.NewGuid().ToString("n");
            Console.WriteLine(guid);//8f1355c0d3084ac7a316d2098550fc4d
            Console.ReadLine();
        }
    }
  
}

 


Posted: 12/12/2010

Professional 8505  points  Professional
  • Joined on: 5/3/2010
  • Posts: 391
  Answered

peter-smith said:

user="peter smith"]

Hi,

I have my GUID as 15208bff-0e77-4439-9dfb-0c6de2b5394c . I need to strip (-) hyphens from it. How can I do it ?

You can also just replace the "-" with String.Empty

Example:

            string Guid = "15208bff-0e77-4439-9dfb-0c6de2b5394c";
            string GuidStripped = Guid.Replace("-", String.Empty);
            Response.Write(GuidStripped);



Page 1 of 1 (3 items)