Desktop Application With C# Slides
Desktop Application With C# Slides
Course
by:Abdimajid Mohamed Ahmed
C# Language
Introduction About This
Languege
C# INTRODUCTION IN EASY
WAY?
C# Comments
Comments can be used to explain C# code, and to make it
more readable. It can also be used to prevent execution
when testing alternative code.
1-Single-line Comments
// This is a comment.
C# Multi-line Comments
2-Multi-line comments start with /* and ends with */.
Any text between /* and */ will be ignored by C#.
This example uses a multi-line comment (a comment block)
to explain the code:
/* The code below will print the words Hello World to the screen,
and it is amazing */
C# Variables
# Variables
Variables are containers for storing data values.
In C#, there are different types of variables (defined with different
keywords), for example:
•int - stores integers (whole numbers), without decimals, such as 123 or -123
•double - stores floating point numbers, with decimals, such as 19.99 or -
19.99
•char - stores single characters, such as 'a' or 'B'. Char values are
surrounded by single quotes
•string - stores text, such as "Hello World". String values are surrounded by
double quotes
•bool - stores values with two states: true or false
C# Datatypes
A data type specifies the size and type of variable values.
1- Int
int myNum = 100000;
Console.WriteLine(myNum);
2-String
string greeting = "Hello World";
Console.WriteLine(greeting);
C# Datatypes
3- Float
float myNum = 5.75F;
Console.WriteLine(myNum);
4-Booleans
bool isCSharpFun = true;
bool isFishTasty = false;
C# Operators
Operators are used to perform operations on variables and values.
In the example below, we use the + operator to add together two values:
if (condition)
{
// block of code to be executed if the condition is True
}
C# Conditions
Else Statement
Use the Else statement to specify a block of C# code to be executed
if a condition is False.
if (condition)
{
// block of code to be executed if the condition is True
}
else
{
// block of code to be executed if the condition is False
}
C# Conditions
Else If Statement
Use the else if statement to specify a new condition if the first
condition is False.
if (condition1)
{
// block of code to be executed if condition1 is True }
else if (condition2)
{
// block of code to be executed if the condition1 is false and condition2 is True }
else
{
// block of code to be executed if the condition1 is false and condition2 is False }
C# Conditions
C# While Loop
The while loop loops through a block of code as long as a specified condition
is True:
int i = 0;
while (i < 5)
{
Console.WriteLine(i); i++; }
C# Loops
C# For Loop
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:
Syntax:
1-ProgressBar
2-Timer
3-TextLabels
Practical Session
About Splash Form
Thank you
Maajid Apdula Ahmed