How to validate GUID is a GUID

后端 未结 9 1791
执念已碎
执念已碎 2020-12-23 15:39

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?

9条回答
  •  一个人的身影
    2020-12-23 16:24

    Will return the Guid if it is valid Guid, else it will return Guid.Empty

    if (!Guid.TryParse(yourGuidString, out yourGuid)){
              yourGuid= Guid.Empty;
    }
    

提交回复
热议问题