C# Programming Language
What is C#-?
C# is a very simple and powerful "Object Oriented Programming Language" Which is developed by Microsoft. It runs on (.NET) frame work. It is pronounced as "C Sharp".
It is developed by (Anders Hejlsberg).
It is used in UNITY game development in core programming language.
It is commonly used in game development.
In 2002 Microsoft released the first version "C# 2.0" with Visual Studio .NET
The latest version of C# is "9.0" which is released in September 2020.
C# programming was created for software development in the .NET framework to create software.
C# has almost all the features of C, C++, Java programming language.
C# is case sensitive programming language and .CS is the extension of C# file.
Using C# we can create:-
1. Mobile Application
2. Web Application
3. Desktop Application
4. Game
5. Database Application etc...,
C# Syntax:-
using system;
namespace first
{
class program
{
static void Main (String [ ] args)
{
console.writeline ("Hello World");
}
}
}
How to download and install application to run programs of C# Click Here
What is Datatype-?
Datatype specifies the different size and value that can be assigned on the variable.
Datatype Size
int 4 bytes
char 2 bytes
bool 1 bit
float 4 bytes
double 8 bytes
string 2 bytes each character
long 8 bytes
What is Variable-?
variable refers to the memory location name where we stored values. Variable is an temporary storage.
If the value is 10 and we want to store it in ram, then we type int a=10, because 10 is an integer value and a is the name of address "1000".
To access the value "10" we type int a =10.
To storage a string value we type string s=shonu, we use variable as name.
Keywords of C# programming language:-
abstract event namespace static
as explicit new string
base extern nul struct
bool false object switch
break finally operator this
byte fixed out throw
case float override true
catch for parrams try
char foreach private typeof
checked goto protected unit
class if public ulong
const implicit readonly unchecked
continue in ref unsafe
decimal int return ushort
default interface sbyte using
delegate internal sealed virtual
do is short void
double lock sizeof volatile
else long stackalloc while
enum
Contextual Keywords of C#:-
add
and
alias
ascending
async
await
by
descending
dynamic
equals
from
_____________________________
get
global
group
init
into
join
let
managed (function pointer calling conversion)
nameof
nint
not
_____________________________
notnull
nunit
on
or
orderby
partial (type)
partial (method)
record
remove
select
_____________________________
set
unmanaged (function pointer calling conversion)
unmanaged (generic type constraint)
value
var
when (filter condition)
where (generic type constraint)
where (query clause)
with
yield
Control flow chart:-
1. Conditional Statement:-
if
if else
nested if
else if
switch statement
2. Looping Statement:-
While
Do while
for loop
3. Jumping Statement:-
Break
Continue
Return
✱ if statement:-
if (condition)
{
|| statement;
}
Flow Chart:-
✱ if else statement:-
if (condition)
{
|| true
}
else
{
|| false
}
Flow Chart:-
✱ Nested if statement:-
if (condition)
{
if (condition)
{
|| statement
}
else
{
code
}
}
else
{
if (condition 3)
{
code
}
else
{
code
}
}
Flow Chart:-
✱ else if leader statement:-
if (condition)
{
|| statement;
}
else if (condition)
{
|| statement 2;
}
else{
|| statement 3;
}
Flow Chart:-
✱ Switch Statement:- (It is also called as decision making statement)
{
case 1: statement 1;
break;
case 2: statement 2;
break;
default: statement 3;
break;
}
Flow Chart:-
while (condition)
{
|| statement;
increment/decrement;
}
Flow Chart:-
Flow Chart:-
{
|| statement;
}
Flow Chart:-
It is used to perform logical and mathematical operatons.
Types of Operators:-
1. Arithmetic:- (+,-,*,/,%)
2. Relational:- (<,>,<=,>=)
3. Equality:- (==,!=)
4. Logical:- (!,&&,||,&,|)
5. Assignment:- (=)
6. Increment & Decrement:- (++,--)
7. Ternary Operator:- (?,:)
Array
Array is variable which help us to store multiple elements of the same type.
10 | 20 | 30 | 40 | 50 |
0 1 2 3 4 ➡ Index
The base index of array with 0 and ends with n-1
Types of Array:-
1. 1D Array
2. 2D Array -- Also called as (Multi-Dimensional Array)
What is string-?
String is nothing but sequence of many characters which are enclosed by double quotes.
for example:-
"SHONU" is a string. It is made up a sequence of 5 characters S,H,O,N,U
What is class-?
Class is prototype defined by a user in which we define the properties and behavior of object.
What is object-?
Object is a instance of a class that represent the class and an object is an real entity that has state and behavior.
What is constructor-?
Constructor is a special type of method whose name is same as class name, it is involved automatically at the time of object creation.
Note:- The main purpose of constructor is used to initialize the data member of new object.
Types of Constructors:-
1. Default Constructor
Syntax:-
class A
{
A( )
{
code
}
}
2. Parameter Constructor
Syntax:-
class A
{
A(int a)
{
code
}
}
What is Encapsulation-?
Encapsulation is a mechanism in which data member and method is wraped in a single unit inside a class so, that the data can't be accessed by the other class
Syntax:-
class A
{
Private data
+
Public methods
}
In programming language some time we have very critical condition on that time we keep our data private. If anyone want to access the data, they will ask to us, then we make our private data to protected data and the only person can access the data who has a permission.
What is inheritance-?
Inheritance allow us to create new classes that reuse, extend and modify the property defined in other classes.
Types of Inheritance:-
1. Single Inheritance
2. Multi-level Inheritance
3. Multiple (through Interface)
4. Hierarchical Inheritance
What is Polymorphism-?
Polymorphism means "many-form", in other word one name with multiple functionalities.
In c# programming language we archieve by the type.
1. Compile Line
↳ Overloading
2. Run Time
↳ Overriding (Inheritance)
No comments:
Post a Comment