manipulating hex in ASP.net

D

darrel

can asp.net handle hex values natively?

I'd like to make a tint of a color spec'd as hex. For instance, turning
ffcc33 into eebb22

Can .net do that natively, or do I need to manually translate ff = 256, cc =
144 etc, and then convert them back after doing my math?

-Darrel
 
G

George

It depends what do you mean "handle hex natively"?

If you want in the compiled code have a hex numbers instead of regular numbers then yes.
Append 0x in front of it.

i = 10;
i = 0x0A; -- same thing.

Other than that there is no support actually.

If you have code like this

string s = "10"

int i = s; ----CAN NOT DO THAT.

int i = Int32.Parse(s) ---- CORRECT.

the same thing if s = 0x0A

int i = Int32.Parse(s, NumberStyles.HexNumber);

---------------------------------------------------------------------

As for the math it does not really matter how you do calculations. 10 or 0x0A is just visible representation of the number.

10*10 = 0x0A*0x0A = 100 = 0x64.


George.

can asp.net handle hex values natively?

I'd like to make a tint of a color spec'd as hex. For instance, turning
ffcc33 into eebb22

Can .net do that natively, or do I need to manually translate ff = 256, cc =
144 etc, and then convert them back after doing my math?

-Darrel
 
S

S. Justin Gengo

Darrell,

Take a look at the System.Drawing.ColorTranslator and
System.Drawing.ColorConverter namespaces.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
 

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

Members online

Forum statistics

Threads
473,767
Messages
2,569,570
Members
45,045
Latest member
DRCM

Latest Threads

Top