Coinage

Ints

May 6th, 2015
283
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.80 KB | None | 0 0
  1. // How to set ints:
  2.  
  3.  
  4. // Ints have to be a integer value.
  5.  
  6. // For example:
  7.  
  8. int number = 500;
  9.  
  10. // Here, you have a int set called number, and its value is 500 currently.
  11.  
  12. // You can change the value of number by doing arithmetic operations on it
  13.  
  14. number = number - 250;
  15.  
  16. // In the example above, number is now 250 less, which means the value is (500 - 250), which is 250.
  17.  
  18. // Here are more examples:
  19.  
  20. number = number * 5;    // number is now its previous value multiplied by 5
  21. number = number - 150;  // number is now its previous value subtracted by 150
  22. number = number / 3;    // number is now its previous value divided by 3
  23.  
  24. // How to use ints
  25.  
  26. // Here is a command I made up. It adds two numbers together if a user says !add <number> <number>
  27.  
  28. if (command.StartsWith("!add")) // This line means if the command said is !add (Basically checks if someone says this command)
  29.   {
  30.        ...  (Some code you will not understand currently I think)
  31.        int number1 = Convert.ToInt32(split[1]);   // this is the first number the user had said.. Since everything are strings            
  32.                                                   // (a string is a line of text), it is required to convert that string
  33.                                                   // to a integer value for arithmetic operation..
  34.        int number2 = Convert.ToInt32(split[2]);   // The second number converted to an integer
  35.        int number3 = number1 + number2;           // number3 is the answer basically, its value is number1 added with number2
  36.        con.Send("say", " Those two numbers added is " + number3); // chat message Bot will say "Those two numbers added is <answer>
  37.    }
  38.  
  39. // That is just an example for a command. There are far more practical and better ways to use ints, but their completely necessary
Advertisement
Add Comment
Please, Sign In to add comment