CodeBetter.Com
CodeBetter.Com
RSS 2.0 via Feedburner
           Do you Twitter? Follow us @CodeBetter

Peter's Gekko

public Blog MyNotepad : Imho { }

CoCreateGuid .net style

For an app I needed some GUID's at runtime. In the COM days I  used the CoCreateGuid for that. In .NET it is much simpler, it is even so simple  I overlooked it and spent far to long looking for a way to import the COM stuff in my code. So let me share what I found in the help file.

The Guid class has a static meber which will get me my guid:

aanmelding.ReplyGuid = System.Guid.NewGuid().ToString();

This one-liner generates a new guid and puts it in string format into my field. That's all.

Peter



Comments

Peter said:

Cool, I could use that to see if the guid the FCL has generated for me is valid. :>
In my case everything is valid as long as it has a high propabillity of being unique.
# April 7, 2004 10:10 AM

Jeff said:

What type of class do you need to declare aanmaelding as?
# June 9, 2004 10:52 AM

Peter van Ooijen said:

Aanmelding is a class describing a subscription appliance. I needed a unique ID for the confirmation e-mail. As subject for the mail, so its just a string.

The point was you can do with the guid whatever you like.
# June 9, 2004 2:57 PM

rohan said:

thanks dude. I also started to import files, but it occured to me to just first google it, and I got your post!

you did save my time

# March 19, 2008 6:24 AM

Leave a Comment

(required)  
(optional)
(required)  

Enter the numbers above:
Add
Check out Devlicio.us!