C # Learning

Source: Internet
Author: User
Tags binary to decimal decimal to binary

// Convert decimal to binary
String str = Convert. ToString (69, 2 );


// Convert decimal to octal
String str = Convert. ToString (69, 8 );


// Convert decimal to hexadecimal
String str = Convert. ToString (69, 16 );

// Convert binary to decimal
String str = Convert. ToInt32 ("100111101", 2 );


// Octal to decimal
String str = Convert. ToInt32 ("76", 8 );


// Convert hexadecimal to decimal
String str = Convert. ToInt32 ("FF", 16 );

 

// In ToString, X represents the string format converted to a hexadecimal string. uppercase/lowercase x represents the case format of the converted string. x is followed by a number: the length of the converted string, which is less than zero.

Int d = 18;

D. ToString ("X4 ");

 

// Exercise the 9 th multiplication table

System. Web. UI. HtmlControls. HtmlForm frm = this. form1;
Label lb = new Label ();
Lb. Text = "9-9 multiplication table ";
Lb. Style. Add ("color", "red ");
Lb. Style. Add ("font-size", "18px ");
Frm. Controls. Add (lb );
For (int I = 1; I <10; I ++)
{
For (int j = 1; j <10; j ++)
{
If (j <= I)
{
Button btn = new Button ();
Btn. Text = string. Format ("{0} * {1} = {2}", I, j, I * j );
Btn. Attributes. Add ("onclick", "alert (this. value); return false ;");
Btn. Style. Add ("position", "absolute ");
Btn. Style. Add ("left", string. Format ("{0} px", j * 75 ));
Btn. Style. Add ("top", string. Format ("{0} px", I * 25 ));
Btn. Style. Add ("width", "75px ");
Btn. Style. Add ("height", "25px ");
Frm. Controls. Add (btn );
}
Else
{
Break;
}
}
}
 

 

 

Related Article

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.