How to handle 404 error in ASP.NET Core 1.0

In this post, we will see different ways to handle HTTP 404 error in ASP.NET Core 1.0 and MVC. I found 2 ways to handle 404 error. In fact using these solutions you can handle any HTTP status code errors. To handle the error, both the solution are using configure() method of Startup.cs class. For those who are not aware about […]

Read More

Extension methods in C#

Extension methods are a new feature in C# 3.0. An extension method enables us to add methods to existing types without creating a new derived type, recompiling, or modify the original types. We can say that it extends the functionality of an existing type in .NET. An extension method is a static method to the […]

Read More

Difference between Value Type and Reference Type

Value Type Reference Type Data stored in stack memory Data stored in heap memory When passed as value type new copy is created and passed so changes to variable does not get reflected back. When passed as Reference type then reference of that variable is passed so changes to variable does get reflected back. Value […]

Read More

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

Nullable type or double question mark in C#

The ?? operator is called the null-coalescing operator. It returns the left-hand operand if the operand is not null; otherwise it returns the right hand operand. Example:- int? x = null; // Set y to the value of x if x is NOT null; otherwise, set y to -1. int y = x ?? -1;

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.

Read More

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

Anonymous method in C#

Anonymous is a type that doesn’t have any name. Anonymous type allows you to create new type by using the new keyword and object initializer syntax without defining its class. The var is used to hold the reference of anonymous types. The Type of anonymous is generated by c# compiler that is accessible within the […]

Read More

Understand Inheritance and Polymorphism with example

In this post, we will understand Inheritance and Polymorphism concept of OOP’S practically. In most of the interviews, interviewers ask these inheritance questions and try to confuse you but after reading this post you will easily understand and clear all your confusion. When you derive a class from a base class, the derived class will inherit […]

Read More

Partial Class

Partial class allows us to split the definition of a class or a struct or an interface over two or more source files. Each source file contains a section of the class definition and all the parts are grouped as a single class when the application compiled. So the main advantage is, it will allow […]

Read More

Connected and Disconnected architecture in ADO.Net

The ADO.NET Framework supports two models of Data Access Architecture: Connection Oriented Data Access Architecture and Disconnected Data Access Architecture. Connected Architecture of ADO.NET In connected architecture, the connection must be opened to access the data retrieved from the database. It was built on the classes connection, command, datareader and transaction. Disconnected Architecture in ADO.NET […]

Read More

AutoMapper in C#

AutoMapper is an object-object mapper which allows you to solve the problem of manually mapping each property of a class with the same properties of another class. AutoMapper saves you the tedious effort of having to manually map one or more properties of such incompatible types. Before AutoMapper was introduced if we wanted to assign […]

Read More