Skip to content

Senabakacak/CsharpFundamentals

Repository files navigation

CsharpFundamentals

Csharp_Fundamentals

I shared my work in c#.

What is C#?

C# is pronounced "C-Sharp". It is an object-oriented programming language created by Microsoft that runs on the .NET Framework

If-Else in C#

Use if to specify a block of code to be executed, if a specified condition is true

Use else to specify a block of code to be executed, if the same condition is false

Use else if to specify a new condition to test, if the first condition is false

Switch-Case in C#

Use the switch statement to select one of many code blocks to be executed.

The switch expression is evaluated once The value of the expression is compared with the values of each case If there is a match, the associated block of code is executed

When C# reaches a break keyword, it breaks out of the switch block.

This will stop the execution of more code and case testing inside the block.

When a match is found, and the job is done, it's time for a break. There is no need for more testing.

LOOPS

Loops can execute a block of code as long as a specified condition is reached. Loops are handy because they save time, reduce errors, and they make code more readable.

WHILE:The while loop loops through a block of code as long as a specified condition is True

DO WHILE:he do/while loop is a variant of the while loop. This loop will execute the code block once, before checking if the condition is true, then it will repeat the loop as long as the condition is true.

FOR:When you know exactly how many times you want to loop through a block of code, use the for loop instead of a while loop

FOREACH:which is used exclusively to loop through elements in an array

ARRAYS

Arrays are used to store multiple values in a single variable, instead of declaring separate variables for each value.