📄️ Variables
Variables are used to store data in a program. A variable is a named memory area in which a value of a certain type is stored. A variable has a type, a name, and a value. The type determines what kind of information the variable can store.
📄️ Data types
Like many programming languages, C# has its own system of data types, which is used to create variables. A data type defines the internal representation of data, the set of values an object can take, and the valid actions that can be applied to an object.
📄️ Arithmetic operations
C# uses most of the operations that are used in other programming languages as well. Operations represent certain actions on operands - participants of the operation. An operand can be a variable or some value (for example, a number). Operations can be unary (performed on one operand), binary (performed on two operands) and ternary (performed on three operands). Let's consider all types of operations.
📄️ Conditional expressions
A separate set of operations represents conditional expressions. Such operations return a logical value, i.e. a value of the bool type: true if the expression is true and false if the expression is false. Such operations include comparison operations and logical operations.
📄️ Construction if...else
Conditional constructs are one of the basic components of many programming languages, which direct the program operation along one of the paths depending on certain conditions. One of such constructs in the C# programming language is the if..else construct
📄️ Cycles
Loops are control constructs, allowing you to execute some action multiple times depending on certain conditions. The following types of loops are available in C#:
📄️ Arrays
An array represents a set of data of the same type. Declaring an array is similar to declaring a variable, except that square brackets are placed after the type:
📄️ Methods
While variables store some values, methods contain a set of instructions that perform certain actions. In essence, a method is a named block of code that performs some actions.
📄️ Parameters of methods
In the last topic, a SayHello method was defined that outputs some message to the console:
📄️ Return value and return operator
A method can return a value, some result. In the example above, two methods were defined that had the void type. Methods with this type do not return any value. They just perform some actions.
📄️ Parameter array and keyword params
In all the previous examples, we used a constant number of parameters. But by using the params keyword, we can pass an undefined number of parameters:
📄️ Recursive functions
Let us consider recursive functions separately. A recursive function is a construction in which a function calls itself.
📄️ Switch design
The switch/case construct evaluates some expression and compares its value with a set of values. And if the values match, it executes a certain code...:
📄️ Enumerations enum
In addition to primitive data types, the C# programming language has such a type as enum or enumeration. Enumerations represent a set of logically related constants.