MessageBox.Show("Hello World!");
String mystring = "This is the value of the string, mystring is the name of the variable."; Int32 myint = 378; //This is a 32bit integer Double mydouble = 378.0001; //This is a double, unlike the integer it can store decimals, it is slower then an integer. It is a member of the floating point family. Decimal mydecimal = 1000.873; //This is a Decimal Boolean mybool = False; //This is a boolean, it can be only true or false. It accepts no other value. Single myfloat = 2008.29; //This is a floating point. mydouble = 64.3 * myint; /*This sets mydouble to 64 times the value of myint. In short, mydouble is now equal to 24305.4. We used a double because it can store decimal places necessary for this value. The / followed by a * surrounding this text is a way to comment out text of multiple lines.*/
Int32 myint; //Initializes the variable, note it was done without setting the variable this time to show you this can be done as well. myint = 10; myint *= 10; //Now myint is equal to 100
Boolean mybool = true; if (mybool == true) //= is used when settings values, == is used when checking values. { MessageBox.Show("This message box is showing because the boolean mybool is equal to true, and thus the requirements of this if statement are met."); }
Boolean mybool = false; if (mybool == true) { MessageBox.Show("mybool is equal to true"); } else { MessageBox.Show("mybool is equal to false"); }
int32 myint = 2; switch(myint) //This specifies we are talking about the value myint. { case(0) : MessageBox.Show("myint is equal to 0"); break; case(1) : MessageBox.Show("we can also format it this way"); break; case(2) : MessageBox.Show("this is what will execute since myint is equal to 2"); break; }
int myint = 75; MessageBox.Show("myint = " + Convert.ToString(myint));
string[] myarray = new string[6]; myarray[0] = "blueberry"; myarray[1] = "plain"; myarray[2] = "raspberry"; myarray[3] = "chocolate"; myarray[4] = "mixed berry"; myarray[5] = "all berries";
int32[,] mymatrix = new int32[2,2]; mymatrix[0,0] = 0; mymatrix[0,1] = 0; mymatrix[0,2] = 0; mymatrix[0,0] = 0; mymatrix[1,0] = 0; //Note i didn't set all the coordinates to show you don't have to.
int Fnumber = 0; int Snumber = 2; while (Snumber < 10) { Fnumber += 1; Snumber += 1; } MessageBox.Show("Finished, it took " + Convert.ToString(Fnumber) + "repetitions to make the second number equal to 10.");
for(int i = 0; Snumber < 10; i++) { Snumber += 1; } MessageBox.Show("Task complete, it took" + Convert.ToString(i) + "repetitions to complete.");
for(int i = 0; i < 10; i++) { MessageBox.Show("Every iteration (cycle, repetition) i is increased by 1 (this is done by ++ which effectively means += 1) until it reaches 10. Since we started at 0 it takes exactly 10 cycles to get there.") //The above message box is shown 10 times before the loop ends. }
int 1int = 5; int 2int = 9; int 3int; 3int = 2int % 1int;
Double mydouble = 1.337; int myinteger = 3; while (true) //The while statement with the value true as an argument signals an infinite loop, broken only by the break statement. { if (mydouble == myinteger / 3) { break; } else { mydouble = Convert.ToDouble(Convert.ToInt32(mydouble)); } }
int position = 0; int[,] 1matrix = new matrix[2,2]; int[,] 2matrix = new matrix[2,2]; for(int i = 0; i < 3; i++) { for(int o = 0; o < 3; o++) { 1matrix[(i - 1),(o - 1)] += 2matrix[(i - 1),(o - 1)]; } }
When in doubt, overclck Steam ID = BobbyDude506RIP Syrillian. Your spirit carries on with us here at OCN.