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

C# Programming Language Basics

Uploaded by

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

C# Programming Language Basics

Uploaded by

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

C# Programming Language Basics ZIAD

OSAMA

C# Basics

Introduction:
The source code or the main project will be at the main function
Main

This
function is
responsible
for
executing
the source
code to
understood
information
to the user

Display on the screen:


Console.Write();

does not go down to a new line


prints all the stings together
at the same line but

Console.WriteLine();

Prints the string and goes


down to a new line

Console.WriteLine(22);

We don’t use double quotes at the


case of numbers if you use it the
number will consider as a string.

Name Space:
Is a type of the classification the C# has some commands and built in functions are used by
calling it’s name space.
Data Types:
byte: is used for the positive real sbyte: is used for the positive and
numbers only. negative real numbers only.
8 bit 8 bit

short: is used for the positive and ushort: is used for the positive real
negative real numbers only. numbers only.
16 bit 16 bit

int: is used for the positive and uint: is used for the positive real
negative real numbers only. numbers only.
32 bit 32 bit

long: is used for the positive and ulong: is used for the positive real
negative real numbers only. numbers only.
64 bit 64 bit
double and float: is used for the decimal: is used for the positive and
positive and negative real and floating negative real and floating numbers.
numbers. 64 bit 32 bit

char: is used for storing just one string: is used for storing a text
character ‘z’. “ziad”.
16 bit

bool: is used for storing true or false. object: is used for anything.
8 bit

Variables:
Data Type Variable Name; this the syntax.

The Variables are used to store Data


inside it are changeable.
Constant Variables: these Variables cannot be changed forever.

error

const Data Type Variable Name; this the syntax.

How to get the ranges of Data Types? DataType.MinValue && DataType.MaxValue

Out put
How to get the number of bytes of Data Types? Sizeof(Data Type)

Printing Data With The Unicode: The Reserved C# Keywords:

The Comments:
//single line comment the comments cannot
/* be executed at the
Multi lines comment code
*/

The Concatenate:

We use + symbol to concatenate more


than one variable together.
Arithmetic Operators:

+ -

* /

% 10 = 3+3+3+1
1 is the rest of the division
Assignment Operators:

Matched Data Types:

Converting in to string & Converting in to number:


Type Casting:
Casting

Type Casting char with the Unicode

Pre Fix & Post Fix:


Logical Operators: and (&&) – or (||) – not (!)

Compression Operators: ==, >=, <= , !=, > , <


Get Value from the user:

Note: Console.ReadLine(); takes sting Data Type and you will convert it as you want.
If Statement:
Switch Case:

Loops:
For Loop
Printing
Character
with for
loop

More than
one
variable at
the for loop

Nested For Loop


Date and Time:

Note: if you want to get the Date and Time as string make the data type from the
string type and convert it to string as you see.
Get all the Part in Date and Time Individual:
You can add days above the date or hours or
months or years.
Current date is 19/2/2025

While Loop:

Do While Loop: at least it will be done one time.


Arrays:

Array.Length
Givs the
length of
array
Foreach Loop: small thing to big things.

Generate Random Number:

10 is the Min and 20 is the Max


20 will not be found.
Random Month.

Upper and Lower Letters:

String Dot Format:


Sub String:

Split String:

You split all the element of


the string in an array of
string Data type.
Replace String:

Reversing String:

Empty String
Regular Expression:
\d Regular Expression is used to representing numbers

Just one
digit

start Expression end

Determine
the digits
(*) means maybe the user enter one digits or not true if
there’s no data.
(+) means at least just one number is inserted or a lot of
data.
(?) means at enter just one digit or nothing.

{7,30} means digits in this range.

\w Regular Expression is used to representing number or characters

\s Is to The Space

Three-letter name
Open name

\| Is to allow to have more than one condition

Check Email

Create Class Functions or Methods File and Call them at Main:


How to create a class?

Right click
The The
created Main
class Program

You create the class is included by the main project and you can make
your functions inside it and you can use them at your main program
application to use the function of class you have to create a variable
from your created class and call it Dot the names of your functions at
your created class.

The Files in C#:


How to create folder: How to delete folder:

How to create File and Write inside it

To save the last data inside it How to delete File

You must close the file to


write your data
How to read Data from File is inside it

Whatever the numbers of lines inside the file will


get it

Try Catch Exception:


It Picks up the errors of the code that is existed inside the try block and
according to the type exception error at the catch will run the code inside this
catch block.

Here the error can’t divide


by zero

The type of error is


Attempted to divide by zero

There is a type of the error


exception it’s called the
Exception
This Exception will be
executed if there is any error
was occurred at the try block
whatever what is it.

Finally in try catch exception it will be


executed if there is no error or not

The End

ZIAD
OSAMA

You might also like