The C# programming language is developed by Microsoft in a .NET initiative by Anders Hejlsberg. It is the simple, object-oriented, and general purpose programming language. C# tutorial provides basic and advanced concepts of C#. Our C# tutorial is for beginners and professionals. C# is common language infrastructure which consists of the executable code and runtime environment. Because of this platform programmer can run different high-level language on different computer platforms and architectures. This tutorial covers all the topic of basic C# programming language. You can find freelancers who know C# programming language.

Simple Example of C# programming

class Program

{

static void Main(string[] args)

{

System.Console.WriteLine(“Hello Everyone”);

}

}

Data Type in C#

  • Bool: bool data type represent a Boolean value that is true and false. By default the value of bool variable is false.
  • Byte: byte data type represent 8bit unsigned integer ranges from 0 to 255. By default, the value of the byte is 0.
  • Char: char represent the 16 bit Unicode character ranges from U+0000 to U+ ffff. By default, the value of char is ‘\0’.
  • Decimal: decimal data type represents the 128-bit precise value with 28-29 significant digits. Its default value is 0.0M.
  • Double: double represent a 64-bit double precision floating point. By default the value of double is 0.0D.
  • Float: float represents the 32-bit single precision floating point. By default, the value of float data type is 0.0F.
  • Int: int represents the 32 bit signed integer type. By default, the value of int data type is 0.
  • Long: long is the 64 bit signed integer type. By default the value of long data type is 0L.
  • Sbyte: sbyte is the 8-bit signed integer type. By default, the value of sbyte is 0.
  • Short: short is the 16 bit signed integer type. By default, the value of short data type is 0.
  • Uint: uint data type is the 32-bit unsigned integer data type. By default, the value of the uint is 0.
  • Ulong: ulong is the 64-bit unsigned integer data type. By default, its value is 0.
  • Ushort: ushort is the 16-bit unsigned integer data type, and by default, its value is 0.

Loop in C#

While Loop:

While loop repetitively executes a target statement as long as given statement is true.

Syntax:

while(condition) {

statement(s);

}

For Loop:

A for loop is same as while loop, but in for loop, you write all structure of loop in the single line.

Syntax:

For (int; condition; increment) {

Statement(s);

}

do…while Loop:

do…while loop is similar to the for and while loop except do…while loop executes statement at least once irrespective of condition.  You can hire freelancers who have complete knowledge of C# programming language.

Syntax:

do

{

Statement(s);

}  while (condition);

 

Nested Loop:

C# allows developer to use one loop inside another loop

Syntax:

for ( init; condition; increment ) {

for ( init; condition; increment ) {

statement(s);

}   statement(s);

}

Encapsulation:

The hiding of one or more items in a physical and logical package is known as encapsulation. The encapsulation concept is implemented in a program using the access specifiers which represent scope and visibility of class member. Following are the access specifiers used in encapsulation.

  • Public
  • Private
  • Protected
  • Internal
  • Protected internal

Polymorphism:

The polymorphism is one of the important aspects of object-oriented programming concept. The polymorphism can be static and dynamic. The response to function gets determined at compile time is known as static polymorphism. In dynamic polymorphism response to function is determined at runtime.

Interface:

The keyword interface is used to declare the interface. The interface declaration is same as the class declaration.

Public interface Drawshape {

// interface members

Void draw();

}

Public class Square : Drawshape

{

Public void draw()

{

Console.WriteLine(“ draw square…”);

}

}

Constructor:

The constructor is the special type of function which is invoked automatically at the time of object creation. The constructor has the same name as class name. There are two types of constructors: default constructor and parameterized constructor.

The default constructor is that constructor which has no argument. The constructor which has an argument is known as a parameterized constructor.

Destructor:

The work of destructor is opposite to constructor. The destructor destroys the object of classes. It can be defined only once in a class same as a constructor it invokes automatically.

Summary:

This article is about the C# tutorial. This article covers all the important basic topics of the C# programming language. Those who want a basic knowledge of C# programming language this article is very beneficial for them.

Kitty Gupta