Using .Net framework 4, I have following input string
String s = "9330e655-63d4-4aee-be79-505554256bd3"
I want to write a function that will return true or false as to whether or not any input string is a valid SqlGuid:
Method 1:
' Parse to validate ...
ok = true
try
s_uid = SqlGuid.Parse( s )
catch e as Exception
ok = false
end try
return ok
However, the ASP.Net framework also provides the Guid.TryParse() method, ie:
Method 2:
' Parse to validate ...
ok = Guid.TryParse( s )
My question: Which is more efficient and what do most use to validate SQL GUIDs (Method 1 or 2)?