Sitecore 5.1.1 API

MainUtil.GetGuid Method (Object, Guid)

Gets a guid from a string.

[Visual Basic]
Overloads Public Shared Function GetGuid( _
   ByVal obj As Object, _
   ByVal _default As Guid _
) As Guid
[C#]
public static Guid GetGuid(
   object obj,
   Guid _default
);

Parameters

obj
A string or other object that can be converted to a guid.
_default
A default value.

Return Value

The guid corresponding to the string.

Remarks

The default value is returned if the string is blank, null or is not a guid. No exception is thrown if the string is not a guid.

Example

  Guid g1 = MainUtil.GetGuid("", GuidsOld.Null); // {00000000-0000-0000-0000-000000000000}
  Guid g2 = MainUtil.GetGuid("{1930BBEB-7805-471A-A3BE-4858AC7CF696}", GuidsOld.Null); // {1930BBEB-7805-471A-A3BE-4858AC7CF696}

See Also

MainUtil Class | Sitecore Namespace | MainUtil.GetGuid Overload List