How For is Different from Foreach Loop in C#

This is very basic question asked in many interviews: The for loop executes a statement or a block of statements repeatedly until a specified expression evaluates to false. There is need to specify the loop bounds (minimum or maximum). Following is a code example of a simple for loop that starts 0 till <= 5. … Read more

Nullable Type in C#

Introduction: Nullable types are introduced in C#2.0. Primitive data type like int, long cannot be assign null. int x = null;//Compile time error Example: Nullable<int> i = null; Nullable Types are instance of System.Nullable<T> struct. [Serializable] public struct Nullable<T> where T : struct { public bool HasValue { get; } public T Value { get; … Read more

Using Tuple in C#

Introduction: Tuple<T> is class in .NET. It is data structure which can hold elements of different data types. It can be used like any entity which can hold element of different data types. We can use Tuple instead of a class with properties. It is introduced in .NET Framework 4.0. Syntax: Tuple<T1,T2,T3,T4,T5,T6,T7,T8> How to Create … Read more

Facade Design Pattern in C#

Why Design Pattern: Design patterns provide general solutions to complex problems There is three categories of design pattern: Creational, Structural, and Behavioral. Facade design pattern comes under structural design pattern. It is used when we want to handle a complex system that has multiple independent subsystems. It provides an abstraction to implement the functionality of … Read more

How to create dynamic JSON?

What is JSON? JSON is java script object notation. JSON is lightweight format used to exchange data between client and server. JSON is easy to read and write. JSON is collection of name/value pair. JSON is language independent. JSON uses JavaScript syntax. JSON format is text only. Example: var jsonObj = {“EmpId”:”1″, “EmpName”: “Rajesh”, “Salary”: … Read more

Method Overloading and Overriding in WCF?

The first question comes in everyone mind that can we overload or override the method in WCF? We will know about this in this article. Method Overloading: Please click below the link to read the concept of method overloading in C#. Method overloading Method overloading is possible in C#. You can think that it is … Read more

Method Overriding in C#.NET

Introduction: Interviewer has ask about method overriding related tricky question in many interview. Definition is simple but many people get confused during interview. I gets confused every time, even though I have read many times. So I thought of writing this article to clear all the doubts.   What is method overriding? There are two … Read more

When to use var keyword in C#?

You must be thinking that there are many data types are provided by .NET Framework then why var is required?   Introduction: Var was introduced in C# 3.0 and .NET framework 3.5. C# is strongly type hence var is also strong type. Type of Var is decide at compile type when we assign value of … Read more