A Place for C Sharpers/.Netters

I Will do coding till last moment of life-Kiran Patil

Posts Tagged ‘generating Guid with .net’

Generating guid(Globally Unique Identifier) with .NET

Posted by kiranpatils on March 19, 2008

I was playing with guid..initially i was getting same guid it was generating same Guid(000-000….)for all time…i was wondering about its strange behaviour..the code what i had written for it is as under:

//Not working

 public static Guid GetGuid()
{
return new Guid()

  }

at last i  found it’s solution:

 public static Guid GetGuid()
{
return Guid.NewGuid();
}

it will give new Guid everytime you call this function..Looks good na??Magic of NewGuid()!!!!

312a12b4-9853-45d2-8ccf-6d59ec940b41

NOTE: you can copy[if you can do try cut ] paste to you class call it.It will give you proper value means GUID

Happy guid!!!

Posted in .NET | Tagged: , | 1 Comment »