Here is a method where we could validate a string as a GUID using Regex pattern matching. It validates the guid case insensitively.
bool IsGuid(string Id)
{
return !string.IsNullOrEmpty(Id) && Regex.IsMatch(Id, "^[A-Za-z0-9]{8}-[A-Za-z0-9]{4}-[A-Za-z0-9]{4}-[A-Za-z0-9]{4}-[A-Za-z0-9]{12}$");
}
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment