Multimobile Development: Building Applications for any Smartphone
Convert from String to GUID
Messages   Related Types
This message was discovered on microsoft.public.dotnet.general.
Responses highlighted in red are from those people who are likely to be able to contribute good, authoratitive information to this discussion. They include Microsoft employees, MVP's and others who IMHO contribute well to these kinds of discussions.

TK Herman
In code I have a String and I want to convert that to a GUID -- is this
possible? How?

SAMPLE:
Dim strValue as String
Dim objGUID as System.GUID

strValue = "{80E9CEF7-1C93-48A7-866C-2002F94379E6}"
objGUID = strValue 'Obviously this doesn't work...

(Note: My GUID is a valid GUID -- I copied one for this sample that SQL
Server automatically created...)

--
Thanks in advance for any help you can provide.

TK Herman
tk.herman_AT_ensi.com

Reply to this message...
Vote that this is a GOOD answer...
 
 
    
Thomas Tomiczek (VIP)
Simple, look at the constructors...
My logic in C#:

String strValue;
Guid objGUID;

strValue = "{80E9CEF7-1C93-48A7-866C-2002F94379E6}";
objGUID = new Guid(strValue);

Regards
--
Thomas Tomiczek
THONA Consulting Ltd.
(Microsoft MVP C#/.NET)

"TK Herman" <Click here to reveal e-mail address> wrote in message
news:#$yFDGagBHA.1640@tkmsftngp05...
[Original message clipped]

Reply to this message...
Vote that this is a GOOD answer...
 
 
    
TK Herman
Wow, do I feel like an idiot!!!! ;)

Thanks for the quick response...

TK

"Thomas Tomiczek" <Click here to reveal e-mail address> wrote in message
news:3c14f519$Click here to reveal e-mail address...
[Original message clipped]

Reply to this message...
Vote that this is a GOOD answer...
 
 
    
Lee Johnson [MS]
You can use the Guid constructor to construct a GUID from string.

Guid g = new Guid("{80E9CEF7-1C93-48A7-866C-2002F94379E6}");

---------------------
This posting is provided ¡°AS IS¡± with no warranties, and confers no
rights.
Reply to this message...
Vote that this is a GOOD answer...
 
 
 
System.Guid




Ad
BootFX
Reliable and powerful .NET application framework.
iOS, Android and Windows Phone Development Training and Consultancy
Hosted by RackSRV Communications
 
Copyright © AMX Software Ltd 2008-2012. Portions copyright © Matthew Baxter-Reynolds 2001-2012. All rights reserved.
Contact Us - Terms of Use - Privacy Policy - 4.0.30129.1734

Hi! 10 years ago I founded .NET 247. I am working on a new and exciting replacement for the site. Please join me on Twitter to discuss.

Thanks,
Matthew Baxter-Reynolds (@mbrit)

Follow mbrit on Twitter