Learn C#_ Learn C#_ Numbers and Operators Cheatsheet _ Codecademy
Learn C#_ Learn C#_ Numbers and Operators Cheatsheet _ Codecademy
Cheatsheets / Learn C#
Console.ReadLine()
The Console.ReadLine() method is used to get user Console.WriteLine("Enter your name: ");
input. The user input can be stored in a variable. This
method can also be used to prompt the user to press
string name = Console.ReadLine();
enter on the keyboard.
Comments
Comments are bits of text that are not executed. These // This is a single line comment
lines can be used to leave notes and increase the
readability of the program.
Single line comments are created with two /* This is a multi-line comment
forward slashes // . and continues until the end
Multi-line comments start with /* and end
of comment symbol is reached */
with */ . They are useful for commenting out
large blocks of code.
Console.WriteLine()
https://www.codecademy.com/learn/learn-c-sharp/modules/learn-c-numbers-and-operators/cheatsheet 1/3
10/3/24, 9:44 PM Learn C#: Learn C#: Numbers and Operators Cheatsheet | Codecademy
Arithmetic Operators
result = 10 * 5; // 50
result = 10 / 5; // 2
result = 10 % 5; // 0
String Interpolation in C#
Console.WriteLine(multipliedNumber);
// This code would output "The multiplied
ID is 1000."
https://www.codecademy.com/learn/learn-c-sharp/modules/learn-c-numbers-and-operators/cheatsheet 2/3
10/3/24, 9:44 PM Learn C#: Learn C#: Numbers and Operators Cheatsheet | Codecademy
Operator Shortcuts
Print Share
https://www.codecademy.com/learn/learn-c-sharp/modules/learn-c-numbers-and-operators/cheatsheet 3/3