How to validate GUID is a GUID

后端 未结 9 1807
执念已碎
执念已碎 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:14

    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

提交回复
热议问题