C # Math Function string and integer replacement

Source: Internet
Author: User

(1) convert hexadecimal strings to Integers // convert string color to int color (for example, # ffffff to 65535)

 
StringArgb = node. selectsinglenode ("Renderstyle/penstyle/pencolor"). Innertext;IntRgbvalue = convert. toint32 (argb,16);
   VaR Colorset = New   String [] { "  # Ff880000  " , " # Ffff0000  " , "  # Ff008800  " , "  # Ff00ff00  " , "  # Ff000088  " , "  # Ff0000ff  " , "  # Ff888800 " , "  # Ff880088  " , "  # Ffff8800  " , "  # Ffff0088  "  }; Temppoly. fillstyle. fillcolor = Convert. toint32 (slopecolor. substring ( 1 ), 16 );

 

Take a certain color component

Because the previous colors are composed of RGB  62580 = 0xf474  The corresponding color: red = 0  Green = 244  Blue = 116  Use it to form the current argb color format, that is, color mycolor = Color. fromargb ( 0 , 244 , 116  ); For any original color, you can: Int Ncolor = 62580  ;  Int Nblue = ncolor % 256  ;  Int Ngreen = (ncolor-nblue )/ 256 ) % 256  ;  Int Nred = (ncolor-ngreen * 256 -Nblue )/ 256 )/ 256 ) % 256  ; Color yournewcolor = Color. fromargb (nred, ngreen, nblue );

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.