|
-
Sep 1st, 2009, 10:41 PM
#1
Thread Starter
Lively Member
[RESOLVED] Typecast String to System.Drawing.Color?
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?
-
Sep 1st, 2009, 10:48 PM
#2
Re: Typecast String to System.Drawing.Color?
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:
Valid names are the same as the names of the elements of the KnownColor enumeration.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|