Tag c switch case

C# String Concatenation

String Concatenation The + operator can be used between strings to combine them. This is called concatenation: Example string firstName = “John “; string lastName = “Doe”; string name = firstName + lastName; Console.WriteLine(name);   Note that we have added…

C# Strings

C# Strings Strings are used for storing text. A string variable contains a collection of characters surrounded by double quotes: Example Create a variable of type string and assign it a value: string greeting = “Hello”;  

C# Math

The C# Math class has many methods that allows you to perform mathematical tasks on numbers Math.Max(x,y) The Math.Max(x,y) method can be used to find the highest value of x and y: Example Math.Max(5, 10);

C# Logical Operators

Logical Operators As with comparison operators, you can also test for True or False values with logical operators. Logical operators are used to determine the logic between variables or values: Operator Name Description Example Try it && Logical and Returns…

C# Comparison Operators

Comparison Operators Comparison operators are used to compare two values (or variables). This is important in programming, because it helps us to find answers and make decisions. The return value of a comparison is either True or False. These values…

C# Assignment Operators

Assignment Operators Assignment operators are used to assign values to variables. In the example below, we use the assignment operator (=) to assign the value 10 to a variable called x: Example int x = 10;

C# Operators

Operators Operators are used to perform operations on variables and values. In the example below, we use the + operator to add together two values: Example int x = 100 + 50;   Although the + operator is often used…

C# User Input

Get User Input You have already learned that Console.WriteLine() is used to output (print) values. Now we will use Console.ReadLine() to get user input. In the following example, the user can input his or hers username, which is stored in…

C# Type Casting

C# Type Casting Type casting is when you assign a value of one data type to another type. In C#, there are two types of casting: Implicit Casting (automatically) – converting a smaller type to a larger type size char…