Postagens

Relational Operators

English: Relational Operators You can also store boolean expression for bool variables, besides "true" or "false" states. If you want to do that, you need to use relational operators. Look at the code below: bool checkNumber = 10 > 5; Which value "checkNumber" stores at this moment? In the code above, we are using one relational operator (>) to check if the value on the left is more than the value on the right. If 10 is more than 5, do you agree that this expression is a truth? If this boolean expression is a truth, the value of "checkNumber" is "true" too. But if you write: checkNumber = 2 > 514; The value from "checkNumber" is false now, because 2 is not more than 514. Returning "true" through from expression above, we can use other relational operator (<) which checks if value on the left is less than value on the right: checkNumber = 2 < 514; At this

Boolean type

English: Boolean Type Boolean variables can only store two values: true or false. As like binary logic, which these values determine how the machine will behaviour. Thinking about that, imagine that you are programming a game, you are able to use a boolean variable to check some actions about player's input. For example, when player, press space key, your hero can attack. Using boolean variable, storage "true" value for one bool type when the player press enter to attack. Now, if your game has an enemy, and if the bool variable is true, it can check if player is attacking him. bool attacking = true; And if player stops to attack, this boolean variable will store "false" value: attacking = false; With these two states, you can control the behaviours around "attacking" variable, like enemies, weapons, energy and anything that depends on this parameter in your game. Português-BR: Tipo Booleano Variáveis ​​boo

Increment and decrement operations

English: Increment and decrement operations Since you know how add +1 to numerical variables, I am able to show you how do that in a different way using increment statement. Incrementing one unit from variable within this syntax: variable++; This increment operation is called post increment, which this variable is incremented by one. Eg: int myVariable = 20; myVariable++; Console.WriteLine(myVariable); // Output will be 21. But, if you try: int x = 2; int y = x++; The Output from "y" will be 2 and from "x" will be 3. Post increment only add +1 for that variable, but doesn't return this value. Look at the code below: int a = 5; int b = a++; int c = a++ - b++; What is the Output from all of these variables after increment operations? Think a little about this question and then check out the answer: The output from "a" variable is 7, because on second and third line, it is incremented.

Assignments Operators

English: Try it yourself to think about one solution to add +1 value to a variable without losing its current value. Do you know how does do that? Simple: add the self value from variable and then plus 1: int variable = variable + 1; "variable" receives its current value and plus one. If "variable" equals 5, now it is 6. As the same way, you are able to do this operation with subtraction and other arithmetics operations: int a = a - 5; int b = b * 20; int c = c / b; int d = d % 2; In C# we have assignments operators besides of "=", to write the operations above, but being a better syntax, check out below: int number += 10; // As the same that: number = number + 10 int a -= 20; // Same as: a = a - 20 int b *= 5; // b = b * 5 int c /= 40; // c = c / 40 int d %= 7; // d = d % 7 Português-BR: Tente você mesmo pensar em uma solução para adicionar +1 ao valor de uma variável sem perder o valor atual. Voc

Aritmethic Operations

English: Since you are using numerical variables, these data types has normal number properties, as math operations. The operations are: Sum + Subtraction - Multiplication * Division / Module % (Is not percentage) Example: int a = 10; int b = 22; int result = a + b; // Output from result is 32. You can also sum float and double variables, not only ints. Other operations: int num = 500, num2 = 200;  int resultSub = num - num2; // Output from resultSub = 300 * AN ALTERNATIVE WAY TO DECLARE VARIABLES IN C#, IN LINE COMMAND, WHEN EACH VARIABLE TO BE DECLARED ARE THE SAME DATA TYPE. int d = 4, e = 10; int f = d * e; // Output 40 int f = 50, g = 2; int h = f / g; // Output 25 int l = 2017, m = 17; int n = l % m; // Output 17 You can write a numerical expression: int result = 16 % 2 + 9; Or more complex: int result = 10 + 22 - 78 / 2 + 8 * 5; Numerical expression in programming is the same math, mul

Variable

English: Variable Storage values is normal practice while you are programming. Remember about the example when our code checks the user's age. The user should enter this information (Input) and code will execute the verification about that data. But... Where this value (age) will be storaged after user's input? To storage values in code, the world of progammation has one principle called variable. Variables are memory spaces in your computer that can "hold" or "storage" values. Think about one shelf with some boxes and inside of these boxes theres random things. Memory space on your computer is the shelf, boxes are variables and storage inside (things) are values to use. If you want to something inside box, you can open it up and get that thing. This You know where find that box. Then, analogy, if you want use some value in your code, you can store it in variable and can recover it to use after. To declare a variable you must def