Converting string to system.type

J

John Dann

I've forgotten something simple here - could someone remind me please:

Dim s as string = "byte"

I want to convert s to its corresponding system.type of Byte. None of
the CType/DirectCast syntax I'm trying seems to be working. eg

dim t as type = ctype(s, type)
 
J

John Dann

Dim s as string = "byte"
Problem solved - I should of course have been declaring:

Dim s as string = "System.Byte"

JGD
 
F

Family Tree Mike

John Dann said:
Problem solved - I should of course have been declaring:

Dim s as string = "System.Byte"

JGD


I guess I don't understand what you were trying to do. This is what I use
to get the type contained in the string:

dim t as Type = System.Type.GetType("System.Byte")
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top