Category Archives: C#

Exception in C#

Another example:

User Define Excepton where throws is use

 

BDJObs.com .NET Class

 

 

 

Base and Sealed class

base class field

//base class method

//calling base class constructor internally

 

 

 

 

Sealed variable not possible:

 

 

 

 

 

C# Generics

Generics Class:

 

 

Generics method:

 

 

 

C# Properties

 

 

Read Only:

 

 

Interface

Interface:

 

Abstract class in C#

 

 

Polymorphism: Method Overloading and Method Overriding and Method Hiding

Method Overriding:

another good exmple:

this video is good for learning overriding:

Method Hiding:

 

Aggregation in OOP

I will discuss more later.

Inheritance in C#

Single Level Inheitance: Inheriting Fields

Single Level Inheritance: Inheriting Methods

Multilevel Inheritance:

Multiple Inheritance Through Interface:

 

 

 

Encapsulation in C#

 

C# Access Modifiers/Specifiers

C# Provides five types of access specifiers:

They are: Public, Private, Protected, Internal, Protected Internal

Public – It specifies that access is not restricted
Protected- It specifies that access is limited to the containing  class or in a derived class
Internal – It specifies that access is limited to the current assembly
Protected Internal – It specifes that access is limited to the current asembly or types from the derived class
Private – It specifies that acess is limited to the containing type

this video will surely help to understand:

Now lets see the example:
public:

protected:

output: it will show error

but we can show the output through some tricks

output:

Internal:

Protected Internal:

private:

eg 1:

eg 2:

 

 

 

 

 

 

 

 

C# Structs works almost like a Class !

 

 

How many constructor a class have in C# ?

Is it known as constructor overloading ?

 

 

C# usage of Static Keyword

Static Class Example:

Static Constructor: