How to cast a STRING to a GUID

Posted by GIbboK on Stack Overflow See other posts from Stack Overflow or by GIbboK
Published on 2010-12-28T17:46:09Z Indexed on 2010/12/28 17:54 UTC
Read the original article Hit count: 437

Filed under:
|

Hi, I need cast a String to a Guid.

I am using this code but

          string myUserIdContent = ((Label)row.FindControl("uxUserIdDisplayer")).Text;
          Guid myGuidUserId = new Guid(myUserIdContent); // PROBLEM HERE
          MembershipUser mySelectedUser = Membership.GetUser(myGuidUserId);

I receive this error

Exception Details: System.FormatException: Unrecognized Guid format.

ANy other ways to do it? thanks

© Stack Overflow or respective owner

Related posts about c#

Related posts about ASP.NET