How to validate GUID is a GUID

001 picture 001 · Jun 2, 2011 · Viewed 137k times · Source

How to determine if a string contains a GUID vs just a string of numbers.

will a GUID always contain at least 1 alpha character?

Answer

Deepesh picture Deepesh · Jun 2, 2011

See if these helps :-

Guid guidResult = Guid.Parse(inputString)

(http://msdn.microsoft.com/en-us/library/system.guid.parse.aspx)

bool isValid = Guid.TryParse(inputString, out guidOutput)

http://msdn.microsoft.com/en-us/library/system.guid.tryparse.aspx