Say I had a string
Dim s as string = "Color.Black"
Is there a way to typecast it into a System.Drawing.Color if it is the exact name of a real color in it?
Printable View
Say I had a string
Dim s as string = "Color.Black"
Is there a way to typecast it into a System.Drawing.Color if it is the exact name of a real color in it?
You can't cast because casting doesn't change the type of the object. You are changing the type of the object, so you're converting, not casting. To do that you should look at the Color.FromName method. As the doco says:Quote:
Valid names are the same as the names of the elements of the KnownColor enumeration.