Thursday, June 18, 2009

Convert string type to unique identifier [VB / C#]

We always want to insert back unique identifier that we have query. Usually we will put it inside session or string. So this is how to convert a string to a unique identifier.

And of course the string must in correct format which is

xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx

Here is a sample:

VB
--
Dim ApplicationId As Guid = New Guid(Session("SampleString").ToString())



C#
--
Guid ApplicationId = new Guid(Session["SampleString"].ToString());

No comments:

Post a Comment