MUST Have C# Interview Questions and Answers – Part 2

By | April 2, 2017
Share on FacebookShare on Google+Tweet about this on TwitterShare on LinkedInDigg thisPin on Pinterest

This C# Tutorial Part-2 in series of C# Interview Questions with practical and detailed answers. In previous part, we covered many basic to intermediate level interview questions on C# with the help of practical examples. I’ll recommend strongly to go through part-1 in this series. We will continue this series to provide more practical details with real time scenarios and complete source code to grasp C# language concepts. But this time, we are understanding in a different way by comparing different concepts.C# Interview Questions and Answers

C# Interview Questions PDF version will be available later for download.

Following Technical Interview Questions and Answers will also be helpful.

Start Date: Aril 01, 2017 12:00 AM PST
End Date: May 01, 2017  6:00 AM PST

Udemy Courses Online

Take All Online Courses – Lifetime Access

Complete C# Interview Questions List

Managed Vs Unmanaged Code

Managed Code:

The code (like Vb.Net,C#,J#) which is written in .Net Framework and developed by .Net Framework and under the control of CLR(Common Language Runtime). And the garbage collector run automatically in managed code.

Unmanaged Code:

The code which is developed outside of the .Net framework is called unmanaged code. Unmanaged code does not run under the control of CLR. Unmanaged code executed with help of wrapper class CCW (COM Callable Wrapper) and RCW(Runtime Callable Wrapper). C++ can be used to write such application.

Back to top

Struct Vs class

Structs and classes are the template or blue print that is used to create an object of a class.

Class Struct
Classes can be inherited Structs are not inherited
Classes are reference type Structs are value type
It could be null It could not be null
Class can be abstract It cannot be abstract
You can override the method within class You cannot override the method within Struct
  • A struct always contain public default parameter less constructor it can not contain the private parameter less constructor.
  • Static constructor is triggered in case of class but not in case of structure.
    Output: This is Constructor B()

Back to top

Abstract Vs Interface

Abstract class and interface both are used to achieve abstraction (for hiding the functionality). Both contain the abstract method.

Abstract Class Interface
Abstract class contain both abstract and non-abstract method Interface contain only abstract method
It contain final, non-final,static,non-static variable It contain only static and final variable
Abstract class provides the implementation of interface It cannot provide implementation of abstract class
It does not support multiple inheritance Interface supports multiple inheritance
Abstract keyword is used to declare abstract class Interface keyword is used to declare the interface

Example of an Abstract class:

Example of Interface:

Back to top

Boxing Vs Unboxing

In C# there is three types of data type Value type,Reference Type and pointer type. The process of the converting a value type into reference type is called Boxing. While the Reference type is converting into value type called unboxing.

Example of Boxing and Unboxing:

Back to top

Method Overloading Vs Method Overriding

Method Overloading Method Overriding
Method Overloading is used for increasing the code readability Method Overriding is used for code re-usability
Parameter must be different Parameter must be same
It can perform within the class It occurs in two classes using inheritance (parent and child class)
It perform compile time polymorphism It perform runtime polymorphism
No special keyword to use for method overloading. It can perform simply within the class. Using virtual keyword with the base class method and override keyword with derived class method can achieved method overriding.

Example of Method Overloading:

Example of Method Overriding:

Back to top

Break and Continue Statements

Break statement is used to break out of loop that’s mean you can jump out of loop at the current position and it terminate the loop.

Continue statement is used to (one iteration) jump over one iteration and again it continues the loop.

Back to top

Constant Vs Read-Only

Constant and Read-only is the keyword that is used to make the field constant that can not be modified.

Constant Value:

Constant variable or local variable are assigned at the time of declaration they cannot be modified after the declaration. Constant variables are static by default hence you cannot use static keyword with the constant field (or variable).


A read-only field can be assigned either at the time of declaration or inside the constructor of the same class, that’s why read only field can be used run-time constant.

Back to top

Ref and out parameters

Ref and out parameters are used to pass an argument into a method. By using this parameter you can return more than one value.

In the case of ref parameter first you need to initialize it then pass to the method but for out parameter, you don’t need to initialize.


The ref keyword is used to pass an argument as a reference. When the value of that parameter will be changed in the method, it will be reflected in the calling method.

It needs to be initialized before passing into the method.


The out keyword is used to pass an argument same as ref keyword but in the case of out ref, you can pass the argument without assigning the value. Instead, it must be initialized in the called method before it returns back to the calling method.

Back to top

String Vs String Builder


String is Reference type data type, you cannot insert, modify or delete any data when a string is created that means in simple word we can say that string is an immutable means once you created the object of string you cannot modify it when you try to modify it will create a new object in memory.

String Builder:

String Builder is an object of string to work with string we have to use a namespace(“Using System. Text) so unlike string, a string builder is an object and we can apply insert, modify and remove function in string builder without creating a new object, It will automatically update in memory does not create new space in memory. We can also say that string builder is mutable that’s mean changeable.

Back to top

Array.copyTo() Vs Array.Clone()

Array.copyTo () and Array. Clone() both areused to replicate the element of existing Single dimension array.


Array.copyTo () method copy the array’s element into existing/destination array with the reference of targeted instance of existing/destination array. You can say that Array.copyTo allows to replicate the into specified index.


Array. Clone () replicate the existing element array in the new array object containing all element of exiting array without having any reference.

Back to top

Dispose and Finalise methods

Memory management is a big challenge when you are developing a web Application/software as we know that Garbage Collector plays the main role in .Net to manage unmanaged resource and Dispose and finalize method both are part of Garbage Collector.

Dispose and finalize method both are used to reclaim the memory used by the unmanaged resource.

Dispose method Finalize method
Unlike Finalize method it is not directly called by GC, User has to write code to implement it. Finalized method is automatically called by GC when any resource goes out of scope or at end of program.
It is a faster method and called by the user for instant object disposal. It is a slower method and automatically called by GC at end of,User can only override method when indeed.
Dispose method is the part IDisposable interface in GC Finalize method is the part of object class in GC
Back to top

Late binding Vs Early binding

If the methods have same name and different parameter declare in a single class or methods have same name and same parameter but declare in different classes then it is called Binding or Polymorphism.

Late Binding:

It is also called runtime polymorphism; the situation arrives when methods are virtual and have same name and same parameter in different classes (must be derived class). Then it is called method overriding or late binding.

Late Binding:

It is also called compile time polymorphism; the situation arrived when methods have same name but different parameter in same class.

It is also called method overloading.

Back to top

IEnumerable & IQueryable

IEnumerable and IQueryable are used for data manipulation in LINQ from the database and collection.

IEnumerable IQueryable
It exists in System. Collections Namespace It exists in System.Linq Namespace
It is the best for query data from in memory collections like List, Array etc. It is best for query data from out-memory (like remote database, Service) collection.
It execute select query on server side, load data in memory on client side and then filter data. It executes select query on server side as well as filtered there.
Suitable for LINQ or Object and LINQ to XML queries Suitable for LINQ to SQL queries
It does not supports the custom query It supports custom query using Create Query and Execute method
It supports lazy loading that’s why suitable for paging It does not support lazy loading that’s why not suitable for paging
Back to top

Throw Exception Vs Throw Clause

Throw Exception Throws Clause
It is used to throw an exception explicitly It is used to declare an exception
It is used inside the method body to invoke an exception. It is used in method declaration(signature)
You cannot throw more than one exception You can throw multiple exceptions
Follow by instance variable Follow by exception class name

Throw Exception Example:

Throws Clause Example:

Back to top

== Vs equals

The == operator compare the reference of the object while the equals compares the contents of the object see the bellow example.

Back to top

Is Vs as operator

Is operator is used to checking the Object type and it returns the Boolean value true if the object is same otherwise returns false.

The as operator perform the conversions between compatible is also work similar as Is operator but instead of return Boolean value it returns the object if they are compatible type otherwise returns null.

Example of Is Operator:

Example of as Operator:

Back to top

Array Vs Array List

Array Array List
Array is collection of similar data types that’s mean we can store only one data type either Int,string,char….etc. Array List is the collection of different data types that’s mean we can store all data types in array list.
The length of array is fixed Array list can decrease or increase dynamically as per usage
Array belongs to System. Array namespace It belongs to System. Collection namespace

Array Example:

ArrayList Example:

Back to top

Directcast Vs ctype

Directcast cType
Directcast is generally used to cast reference data type. It is used to cast value type.
To perform the Directcast between two different classes, the classes should have relationship between them. To perform ctype b/w two different value types, relationship is not required. If the conversion is legal it will be performed.
When you perform Directcast on arguments that do not match it will throw InvalidCastException. Exception is not thrown while perform ctype.
Performance of Directcast is better than ctype because there is no runtime helper routines of VB.Net are used for casting. It requires runtime helper routine of VB.Net hence performance is slow that Directcast.
Directcast is portable across many language that’s mean it is not specific to VB.Net Ctype is not portable it is specific to VB.Net.

Directcast Example:

Type Cast Example:

Where obj is  Typecast

Back to top

Public Vs Static Vs void

Public: public keyword is access modifier and tells the c# compiler that the Main method is accessible by anyone.

Static: static keyword declared that the Main method is global and can call without creating an instance of the class.

Void: void keyword is used to specify that the Main method does not return any value.

Example of public and static keyword:

Back to top

Top Technical Interview Questions and Answers Series:

Top C#.NET Jobs [Updated Daily]


Junior .NET Developer
Source: Publishers Clearing House
Details: Windows Forms, WCF, ASP.NET, MVC. Publishers Clearing House (PCH), headquartered in Port Washington, NY (soon to be Jericho, NY!)....  More
14 days ago

Port Washington, NY 11050 12-April-2017

Senior .Net Developer
Source: Indeed
Details: Excellent server side development in ASP.NET, MVC, ADO.NET, LINQ, Web API, Windows Service and. We are looking for a strong, well rounded, self-motivated web...  More
4 days ago

Kingwood, TX 22-April-2017

Software Engineer C#/ASP.NET MVC/JavaScript
Source: Cormant, Inc.
Details: You will be working on full stack development including Marionette client, and a C# MVC architecture with NHibernate/RDBMS as the back-end....  More
5 days ago

San Luis Obispo, CA 21-April-2017

.NET Software Engineer
Source: CCC Information Services Inc.
Details: Sr. .NET Developer Cerritos, CA CCC Information Services, Inc. CCC provides the technology, data and insight needed to help our customers make informed,  More
5 days ago

Cerritos, CA 21-April-2017

Junior .Net Developer
Source: MassMutual Financial Group
Details: Experience working with WPF, CSS, Classic ASP, Infragistics controls, and SharePoint a plus, but not required. Junior .Net Developer....  More
20 days ago

Charlotte, NC 06-April-2017

Senior .Net Developer (Full-Stack)
Source: Indeed
Details: 4+ years of C# .NET and ASP.NET MVC development. Design, develop, and deliver web application components for a distributed system....  More
8 days ago

Austin, TX 18-April-2017

.Net Develoer
Source: conrep
Details: Experience with ASP.NET MVC and Bootstrap. The candidate also will work on the new custom modules/web sites developed in ASP.NET MVC C# platform....  More
12 days ago

Harrisburg, PA 17112 13-April-2017

Senior.Net Web Developer
Source: Indeed
Details: MVC. Our client – an established yet growing eCommerce firm seeks an accomplished .Net developer to fill a key role in the development of public-facing web...  More
6 days ago

Springfield, PA 19-April-2017

Senior .NET Developer
Source: Indeed
Details: *U.S. Citizens and those authorized to work in the U.S. are encouraged to apply. We are unable to sponsor at this time.* *Job Description: Senior .NET  More
14 days ago

Bloomfield, MI 12-April-2017

Junior to Mid-level .Net Developer
Source: Indeed
Details: Experience with the MVC pattern for web development. US Citizens or Greencard that do not require a Visa Sponsorhip for Full-Time Employment*....  More
7 days ago

Englewood, CO 18-April-2017

Junior .NET Developer
Source: NIC
Details: MVC. In-depth experience with C#, ASP.NET and MVC. Junior .Net Developer Position....  More
30+ days ago

Baton Rouge, LA 23-March-2017

.NET Software Engineer (Front End or Back End)
Source: Indeed
Details: Full stack Engineers will also get to work on our Front End within a ASP.NET MVC + JavaScript environment....  More
9 hours ago

San Diego, CA 92122 26-April-2017

Junior .NET Web Developer
Source: Indeed
Details: 1+ years experience ASP.NET MVC. The Award Zone provides tools for organizations to provide highly-effective motivational programs, such as employee reward and...  More
14 days ago

Atlanta North, GA 11-April-2017

Senior Software Developer .NET ASP.NET MVC
Source: Indeed
Details: Build new applications with .Net (C#) & ASP.NET MVC – heavy focus on client web portal. Reporting to the Vice President, Technology, the Senior Software...  More
25 days ago

New York, NY 10006 31-March-2017

Sr. C#/ASP.NET Developer
Source: Logic20/20
Details: *Strong C#, .NET framework (ASP.NET MVC, Entity Framework), jQuery, HTML 5 development Qualifications. Logic20/20 is a Seattle based Management & Technology...  More
8 days ago

Seattle, WA 98115 18-April-2017

Software Developer
Source: Indeed
Details: Experienced in ASP.NET MVC 5, CSS3, HTML5, JavaScript, JQuery, Knockout.js and AngularJs. This would be a managed service position:....  More
9 days ago

Seattle, WA 16-April-2017

.NET Software Engineer
Source: Shipbob
Details: We have opportunities to solve our clients needs with a wide variety of frameworks and platforms such as ASP.NET MVC, Azure SQL Server, Angular and many more....  More
20 days ago

Chicago, IL 06-April-2017

Software Development Engineer (.NET)
Source: Indeed
Details: Talentry is looking for a solid .net developer (c#, WCF, MVC, angular) with good communication skills who likes the idea of working in an environment that...  More
22 days ago

Irvine, CA 03-April-2017

Full stack .Net Mobile Application Developer
Source: Posh Technologies
Details: Visual Studio 2013+, C#, ASP.NET MVC 5 and Web API 2. 5+ years of working experience with C#, ASP.Net MVC, SQL Server, JavaScript....  More
5 days ago

Redmond, WA 21-April-2017

Software Engineer, Jr.
Source: Indeed
Details: HTML, HTML5, MVC, JavaScript, CSS, XML, SQL Server 2008/2014, Restful web services, AJAX, Testing Automation and OOD....  More
26 days ago

Phoenix, AZ 30-March-2017

Sitecore Developer
Source: Ursus Incorporated
Details: Solid experience with C#, ASP.NET, MVC, JavaScript, HTML5, CSS3, Razor. About the Role:....  More
19 hours ago

Sacramento, CA 95834 25-April-2017

Senior C#/.NET Full Stack Developer
Source: Graphic Products
Details: 3+ years demonstrated experience in ASP.NET MVC 4/5+. We are looking for a Senior Full Stack Developer responsible for the ongoing development and advancement...  More
30+ days ago

Beaverton, OR 97008 09-March-2017

Junior .NET Developer (no 3rd party candidates)
Source: Indeed
Details: Candidate must be clearable for a federal government public trust clearance; no third party candidates. *Responsible for developing and supporting .NET/C#  More
30+ days ago

Herndon, VA 16-March-2017

Front End Developer
Source: Indeed
Details: Microsoft ASP.NET MVC experience. Design, develop, and deliver front end web application components for a distributed system....  More
4 days ago

Annapolis, MD 21401 21-April-2017

.NET/C# Software Integration Engineer
Source: BlueVolt
Details: Solid programming experience with C#, WCF, Restful services using WEB API, and ASP.NET MVC. BlueVolt is growing....  More
29 days ago

Portland, OR 27-March-2017
Share on FacebookShare on Google+Tweet about this on TwitterShare on LinkedInDigg thisPin on Pinterest