Monday, December 04, 2006

Converting String GUID to System.Guid

Simple matter. I was trying to convert the GUID in string to type of System.Guid and the code below apparently did not work for me.

System.Guid guid = (System.Guid)strGUIDInString;

I was given invalid specified cast error message and I noticed that direct casting wasn't the way. I ended up with

System.Guid guid = new System.Guid(strGUIDInString);

This was the final solution I could think of, so far !

1 comment:

David said...

Yup, that's the way it is. Direct cast is not allowed because the two are different types :)