A Class is an encapsulation of properties(member variables) and methods that are used to represent a entity. Class is a data structure that brings all the member variables together in a single unit.
An Object in an instance of a Class. Technically, it is just a block of memory allocated that can be stored in the form of Variables, Array or a Collection.
The following are the fundamental concepts of Object Oriented Programming:
Code which is executed by CLR (ommon Language Runtime) in .NET Framework is called managed code because CLR handle security, manage unused memory ,debugging and so on. The code which is developed by other Framework not .NET Framework is called unmanaged code.
An Interface is a class with no implementation. The only thing that it contains is the declaration of methods, properties, and events.
The different types of class in C# are:
Partial class – Partial class is special features of c#,it provides ability to implement a single class functionality to multiple .cs files. Partial class is create by Partial keyword.
Sealed class – Sealed class is a class that cannot be inherited by other classes. The sealed modifier is used to define a class as sealed in c#.
Abstract class – Abstract class cannot be instantiated. Abstract class can only be inherited. It should contain at least one method. It is denoted by the keyword abstract.
Static class – Static class can not be instantiated.Its member variables and methods can be static only. It is defined using static keywords.
C# compiler compiles the C# code into MSIL code (Microsoft Intermediate Language). MSIL code can not executed directly by CPU so CLR Compiles the MSIL code to native code by using the Just-In-Time (JIT) compiler (or JITter).
Virtual methods have method definition and derived classes have option of overriding it, but Abstract methods do not have implementation and derived classes have to override the methods.
Exception handling in C#:
There are three ways to pass parameters to a method −
Value Parameters − The argument value are copy to formal parameters of function. There are no effect on value of argument if change the value of function parameter inside function body.
Reference Parameters − Copy the reference of an argument into the formal parameter.In this case if function parameters value will change inside function body ,argument value will change.
Output Parameters − It helps in returning more than one value.
Boxing- When a value type converted to object type is called boxing.
Unboxing- When a object type converted to value type is called unboxing.
Reflection provides metadata (assemblies, modules and types) of objects type. Reflection helps to dynamically create an instance of a type, bind the type to an existing object, or get the type from an existing object and invoke its methods or access its fields(name etc) and properties.
public class MyClass
public virtual int Add(int numb1, int numb2)
return numb1 + numb2;
public virtual int Subtract(int numb1, int numb2)
return numb1 - numb2;
static void Main(string args)
MyClass oMyClass = new MyClass();
Type oMyType = oMyClass.GetType();
MethodInfo oMyMethodInfo = oMyType.GetMethod("Subtract");
Console.WriteLine("nType information:" + oMyType.FullName);
Console.WriteLine("nMethod info:" + oMyMethodInfo.Name);
Uses of Reflection in C#-
Yes we can have only try block without catch block but we have to have finally block.