C Sharp Tutorial

Welcome to Tech Altum C# Tutorial. In this tutorial we will first learn the fundamentals of object oriented like what is class and object, Constructor, Inheritance, Access Specifier, Abstract Class, Polymorphism, Generics, Collection, Grabage Collection etc with Practical example and Interview Questions.

Class and Constructor

Introduction of Class and Constructor

Class is the way to realize real time entity in oops. It is the user defined data type.

Syntax of Class

Constructor

Type of Constructor

There are two types of constructor and these are following:-

Static Constructor(also known as class constructor)

Constructor Type

Constructor Chaining

If you ask the question that can we call constructor from another constructor then I will say yes we can. Calling constructor from another constructor is known as constructor chaining. This can be done by the keyword this and base. Here we discuss on this keyword and will discuss base keyword in the article constructor with inheritance.

Constructor Chaining

Difference between function and constructor

We can give any suitable name to function but constructor name will be the name of class.

Function v/s Constructor

Static Variable in C#

Static Variable is also known as class variable. It is declared like a global variable. Static variable is called using class name. We cannot call static variable with object

static variable

Static Constructor V/S Non Static Constructor

We have two types of constructor. Static Constructor and Non Static Constructor. In this artical we have discussed the difference between static constructor and non static constructor

static Constructor V/S Non Static Costructor

Inheritance

Implementation of Inheritance

Inheritance is property of oops by which we access one class into another class without writing the whole code. The class that is inherited is called base class and the class that does the inheritance is called a derived class

Inheritance

Base Class Constructor Calling from Derived Class

When we inherit class into another class then object of base class is initialized first. If a class do not have any constructor then default constructor will be called.

Base class constructor calling

Access Specifier with Example

Access specifier defines the accessibility of class member. We can restrict and limit the accessibility of member of classes.

Access Specifier

Override and New in C#

At the time of overloading we generally use override with virtual. When we need to override the base class method into derived class than we use override keyword.

Overried and New

Interface in Detail

Interface Implementation with Runtime Polymorphism

Interface in C# is basically a contract in which we declare only signature. The class which implemented this interface will define these signatures. Interface is also a way to achieve runtime polymorphism. We can add method, event, properties and indexers in interface

Interface

Abstract Class V/S Interface

An Abstract class has been created using Abstract keyword while interface has been created using interface keyword.

Difference between Abstract Class and Interface

Array in C Sharp

One Dimensional Array in C sharp

Array in C sharp is basically continues memory allocation of given type and size. We create array by using [].

Array Declaration

int[] data = new int[5];

Arrays

Searching in Array

To search any element in array we use Contains Function. This function is declared and defined in Array class. We have to pass the value in this method. If this value available in the given array then it will return true and if not then it will return false.

Array Searching

Merging in Array

To search any element in array we use Contains Function. This function is declared and defined in Array class. We have to pass the value in this method. If this value available in the given array then it will return true and if not then it will return false.

Array Merging

Jagged Array in C sharp

Jagged array is simply an array of arrays. As we define 2-d array in which each column for each rows are same. But in case of jagged array we can define different column for each rows.

Jagged Array

Operator Overloading

Implementation of Operator Overloading

Before understanding the operator overloading we need to understand why we use operator overloading. In the following example we have one class calculator which contains two variable x and y. and one web form where we create two variables in its cs file and add them.

Operator Overloading

Generics and Collection

Implementation of IEnumerator and IEnumerable Interface and Yield Keyword

In simple term collection in C# is a way to store objects. We use System.Collection namespace to work with collection.

IEnumerable and IEnumerator