The Infinite Loop – Beginner's SEO, Beginner C# & JQuery Tutorials Problem. Problem Solved. Loop. – The life of a programmer

14Aug/090

Creating/Retrieving a GUID object from a string C#

GUIDS are great to use if you ever may need to merge data.
The chances of collision (duplicates) are extremely low.

To generate a new guid, use this code:
Guid g=Guid.NewGuid(); //this generates a GUID object
Guid g2=Guid.NewGuid().ToString(); //this generates a GUID string





There may be a time where in a stored procedure, you have a GUID as a parameter.

In C# you may have to pass this paramater to the procedure.
This is actually very simple.

Given a string that you know is a GUID, you can retrieve a guid object like so:
Guid g=new Guid(myStringGUID);

And thats all folks :)

Share and Enjoy:
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • Slashdot
  • StumbleUpon
  • Technorati
  • Yahoo! Buzz
Comments (0) Trackbacks (0)

No comments yet.


Leave a comment

No trackbacks yet.