What is an Object and a Class?

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.

What is C#?

C# is a programming language developed by Microsoft, it is a general-purpose, multi-paradigm programming language with features of strong typing, imperative, declarative, functional, generic, object-oriented, and component-oriented programming disciplines.

What are the fundamental OOPs concepts?

The following are the fundamental concepts of Object Oriented Programming:

  • Encapsulation – It is process of binding data and functions(methods) within on unit. It also hide the internal state of an object from outside.
  • Abstraction – It is a process of displaying only essential information and hide the irrelevant characteristics.
  • Inheritance – It is a mechanism where one class acquire the properties and behaviour of another class to achieve reusability.
  • Polymorphism – Polymorphism means more than one forms. It is achieved by having multiple methods with the same name but different signature.

What is Managed and Unmanaged code?

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.

What is an Interface?

An Interface is a class with no implementation. The only thing that it contains is the declaration of methods, properties, and events.

What are the different types of classes in C#?

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.

Explain Code compilation in C#.

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).

What is the difference between Virtual method and Abstract method?

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.

How to handling exception in C#?

Exception handling in C#:

  • try – Contains a block of code that can throw an exception.
  • catch – catch block handle when an exception is thrown.
  • finally – Finally block get executed whether exception occurred or not.
  • throw – Throw is a keyword used to trigger an exception when a error occurs in program.

In how many ways you can pass parameters to a method 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.

What is boxing and unboxing in C#?

Boxing- When a value type converted to object type is called boxing.
Unboxing- When a object type converted to value type is called unboxing.

What Is Reflection in c#?

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 information.

Type oMyType = oMyClass.GetType();

//Method information.

MethodInfo oMyMethodInfo = oMyType.GetMethod("Subtract");

Console.WriteLine("nType information:" + oMyType.FullName);

Console.WriteLine("nMethod info:" + oMyMethodInfo.Name);



Why we need reflection In C#?

Uses of Reflection in C#-

  • To detect dependencies of an assembly.
  • Determining the contents of an unknown assembly or object.
  • Debugging - exploring a list of the loaded assemblies, their references, current methods etc.
  • In serialization, it is used to serialize and de-serialize objects
  • To confirm location types such as an interface, derive from base, abstract class search member by attributes.

What Is Generics?

Generics are the most powerful features of c#. Generic allows programmer to write reusable code and methods for all data types. It improve type safety and performance.

What is difference between String and Stringbuilder ?

Difference between String and Stringbuilder:


  • Defined in System namespace.
  • Immutable(readonly) instance.
  • Performance degrades when continuous change of value occures.
  • Thread safe.


  • Defined in System.Text namespace.
  • Mutable instance.
  • Btter perfomance because new changes are made to existing instance.
  • Not thread sefe.

What are IDE’s provided by Microsoft for C# development?

The following are the IDE’s used for C# development –
  • Visual Studio Express (VCE)
  • Visual Studio (VS)
  • Visual Web Developer

Explain sealed class in C#?

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#.

List out the differences between Array and ArrayList in C#?

  • Array stores the values or elements of homogenous data type but arraylist stores values or elements of heterogeneous datatypes.
  • Array uses the fixed length but arraylist does not uses fixed length like array.

What is the difference between “dispose” and “finalize” variables in C#?

  • Dispose method uses interface IDisposable and it will free up both managed and unmanaged codes like – database connection, files etc.
  • Finalize method is called by garbage collector automatically and cannot be called from the code.

Can we have only “try” block without “catch” block in C#?

Yes we can have only try block without catch block but we have to have finally block.

Back to Top