creating color object

F

fragget

hi

i have a string like "ffff032d" which represents
a color.

i want to create a color object given this value
but am having trouble.

this is what i have so far.

Color myColor = Color.FromArgb(Convert.ToInt32
("ffff032d"));

it fails to convert the string to an int.


thx - fg
 
N

Nicholas Paldino [.NET/C# MVP]

fg,

When converting the string, you should be able to do the following:

// Get the color.
Color myColor = Color.FromArgb(Convert.ToInt32("fffff032d", 16));

The ToInt32 method allows you to specify the base that you want to
interpret the string in.

Hope this helps.
 

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