Interview questions and answers for 3-8 year experience

What is the difference between an abstract class and interface? When would you want to use them? OOP Concepts practical questions example in C# Static Class in C# What are Anonymous methods? What is the difference between Finalize()and Dispose()? What is the difference between ref and out parameters? What is the difference between Var, object… Read More »

Where is View State data stored in asp net?

View State data is stored in a hidden field called “__VIEWSTATE” on a Web page. It stored data in Base64 String encoded format which can be further decoded. Sample hidden field looks like below: <input type=”hidden” name=”__VIEWSTATE” id=”__VIEWSTATE” value=”/wEPDwUKMTM1ODM3Nj…….” /> This single hidden field contains all the viewstate values for all the page controls. You… Read More »

Event vs Delegate

Event and Delegate are interrelated. In this post, we will learn how they are different each other. An Event declaration adds a layer of abstraction and protection on the delegate instance. This protection prevents clients of the delegate from resetting the delegate and its invocation list and only allows adding or removing targets from the… Read More »

Difference between Singleton and Static class

A singleton classes allowed to create a only single instance or particular class. That instance can be treated as normal object. You can pass that object to a method as parameter or you can call the class method with that Singleton object. While static class can have only static methods and you can not pass… Read More »

LINQ Single vs SingleOrDefault vs First vs FirstOrDefault

Single(), SingleOrDefault(), First() and FirstOrDefault() are extension methods of the Enumerable class. Many people get confused about the difference between Single, SingleOrDefault, First, and FirstOrDefault methods in Linq. Let’s understand the difference between all these methods as below: Single() SingleOrDefault() First() FirstOrDefault() Description Returns a single, specific element of a sequence Returns a single, specific… Read More »

Constructor Chaining in C#

Constructor chaining is an approach where a constructor calls another constructor in the same class or base class. It is very useful when we have a class that defines multiple constructors. Before knowing how to use constructor chaining in C#. Let’s first see why we need constructor chaining. Example: we have a class call “Employee”… Read More »

Difference between throw and throw ex

We can say “throw” maintains the full hierarchy in the stack trace and gives complete information about the exception occurred in the code. Whereas “throw ex” pretends that exceptions occurred on the line where “throw ex” was written and removes all the hierarchy above the method containing the “throw ex” expression.

Difference between IEnumerator and IEnumerable

IEnumerable An enumerable class implements the IEnumerable interface. The IEnumerable interface has only one method GetEnumerator, which returns an IEnumerator interface. public IEnumerator GetEnumerator(); Example:- class Program { static void Main() { List<int> list = new List<int>(); list.Add(1); list.Add(2); list.Add(3); list.Add(4); list.Add(5); List<int>.Enumerator e = list.GetEnumerator(); Write(e); } static void Write(IEnumerator<int> e) { while (e.MoveNext())… Read More »

How to start a Thread in C#

We have to use the Thread class provided by System.Threading namespace. In the constructor of the class, we have to pass the method name which we want to run in separate thread. After than we have to call the start method of Thread class. Example:- using System; using System.Threading; namespace ConsoleApplication1 { class Program {… Read More »