0% found this document useful (0 votes)
29 views26 pages

Desktop Application With C# Slides

This document provides an introduction to the C# programming language, detailing its uses in various applications such as web, mobile, and game development. It covers fundamental concepts including syntax, comments, variables, data types, operators, conditions, and loops, along with practical examples. Additionally, it suggests using Visual Studio Community as an IDE for C# development.

Uploaded by

maajidmohamed57
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views26 pages

Desktop Application With C# Slides

This document provides an introduction to the C# programming language, detailing its uses in various applications such as web, mobile, and game development. It covers fundamental concepts including syntax, comments, variables, data types, operators, conditions, and loops, along with practical examples. Additionally, it suggests using Visual Studio Community as an IDE for C# development.

Uploaded by

maajidmohamed57
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 26

Desktop Application

Course
by:Abdimajid Mohamed Ahmed
C# Language
Introduction About This
Languege
C# INTRODUCTION IN EASY
WAY?

C# is used to develop web apps,


desktop apps, mobile apps, games and
much more.
It is an object-oriented programming
language created by Microsoft that runs
on the .NET Framework.
What is used for?
C# is used for:
•Mobile applications
•Desktop applications
•Web applications
•Web services
•Web sites
•Games
•VR
•Database applications
•And much, much more!
Why is used for?
•It is one of the most popular programming languages in the
world
•It is easy to learn and simple to use
•It has huge community support
•Most One for using Desktop Applications even Java.
How to get started it?
The easiest way to get started with C# is to use an IDE.
An IDE (Integrated Development Environment) is used to edit
and compile code.
In our tutorial, we will use Visual Studio Community, which is
free to download from
https://visualstudio.microsoft.com/vs/community/.
Applications written in C# use the .NET Framework, so it makes
sense to use Visual Studio, as the program, the framework, and
the language, are all created by Microsoft.
C# syntax?
using System;
namespace HelloWorld
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello World!");
}
}
}
Comments, Variables, Datatypes

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

Single-line comments start with two forward slashes (//).

// 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:

int x = 100 + 50;

In this course we took only four operators which are:

1-Arithmetic Operator: mathematical operations


2-Assignment Operator: assign values to variables.
3-Comparison Operator: compare two values (or variables)
4-Logical Operator: determine the logic between variables or values
C# Conditions
If Statement
Use the if statement to specify a block of C# code to be executed
if a condition is True.

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

int time = 22;


if (time < 10)
{
Console.WriteLine("Good morning."); }
else if (time < 20)
{
Console.WriteLine("Good day."); }
else
{
Console.WriteLine("Good evening."); }
// Outputs "Good evening."
Explanation
In the example above, time (22) is greater than 10, so the first condition is False.
The next condition, in the else if statement, is also False,
so we move on to the else condition since condition1 and condition2 is both False - and
print to the screen "Good evening".

What, if the time is 14, our program would print “---------”


C# 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.

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:

for (statement 1; statement 2; statement 3) { // code block to be


executed }

Statement 1 is executed (one time) before the


execution of the code block.
Statement 2 defines the condition for executing
the code block.
Statement 3 is executed (every time) after the
code block has been executed.
C# Loops
for (int i = 0; i < 5; i++)
{
Console.WriteLine(i); }
C# Splash/Launch form

phical user interface that appears when an application starts or logs in


Every Splash/launch form consist:

1-ProgressBar
2-Timer
3-TextLabels
Practical Session
About Splash Form
Thank you
Maajid Apdula Ahmed

You might also like