manipulating hex in ASP.net

Discussion in 'ASP .Net' started by darrel, Oct 6, 2005.

  1. darrel

    darrel Guest

    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
    darrel, Oct 6, 2005
    #1
    1. Advertising

  2. darrel

    George Guest

    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.

    "darrel" <> wrote in message news:%...
    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
    George, Oct 6, 2005
    #2
    1. Advertising

  3. 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
    "darrel" <> wrote in message
    news:%...
    > 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. Justin Gengo, Oct 6, 2005
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. darrel

    manipulating hex values

    darrel, Mar 1, 2006, in forum: ASP .Net
    Replies:
    5
    Views:
    559
    Kevin Spencer
    Mar 3, 2006
  2. Replies:
    10
    Views:
    6,191
    Neredbojias
    Aug 19, 2005
  3. Bengt Richter
    Replies:
    6
    Views:
    466
    Juha Autero
    Aug 19, 2003
  4. Stephen Cattaneo

    manipulating hex values

    Stephen Cattaneo, Apr 1, 2008, in forum: Python
    Replies:
    0
    Views:
    284
    Stephen Cattaneo
    Apr 1, 2008
  5. Stephen Cattaneo

    Re: Re: manipulating hex values

    Stephen Cattaneo, Apr 1, 2008, in forum: Python
    Replies:
    1
    Views:
    545
    Stephen Cattaneo
    Apr 3, 2008
Loading...

Share This Page