Converting string to system.type

  • Thread starter Thread starter John Dann
  • Start date Start date
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)
 
Dim s as string = "byte"
Problem solved - I should of course have been declaring:

Dim s as string = "System.Byte"

JGD
 
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")
 
Back
Top