creating color object

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • fragget

    #1

    creating color object

    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
  • Nicholas Paldino [.NET/C# MVP]

    #2
    Re: creating color object

    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.


    --
    - Nicholas Paldino [.NET/C# MVP]
    - nicholas.paldin o@exisconsultin g.com

    "fragget" <fragget@home.c om> wrote in message
    news:02fa01c34b 0d$08c8c7e0$a40 1280a@phx.gbl.. .[color=blue]
    > 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[/color]


    Comment

    • fragget

      #3
      Re: creating color object

      awesome, thanks.

      On Tue, 15 Jul 2003 16:19:11 -0400, "Nicholas Paldino [.NET/C# MVP]"
      <nicholas.paldi no@exisconsulti ng.com> wrote:
      [color=blue]
      >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.[/color]

      Comment

      Working...