C#

C# Action

Action is one of the pre-built delegates in C# to store a method reference. The action delegate only accepts those methods that have a void return type. The action delegate has 16 overload methods that allow you to store a method reference that can accept up to 16 parameters. In …

C# Action Read More
C#

C# Predicate

Predicate is a pre-built delegate in the .NET framework class library. Delegates are used to store method which has same parameters and return types as specify in the delegate type. Predicate is a generic delegate. It takes one parameter and returns a boolean value. Predicate delegate is used for check whether a parameter meets …

C# Predicate Read More
C#

C# Func

In the Microsoft Framework class library, there are some built-in delegates. Action, Predicate, and Func are some of them. I have explained Action and Predicate in my previous posts. Action and predicate delegates have restrictions. The action delegate can only take parameters and does not return anything. A predicate delegate can …

C# Func Read More
C#

C# Interface

C# Interface defines a group of related functionality. An interface defines only the definition of the functionality. All classes and structures which inherit from interface must implement the functionality defined in an interface. We can not create an instance of interface. In the interface declaration variable, we can only store the …

C# Interface Read More
C#

C# Versions and Features

C# versions C# 1 comes in 2002 with .NET framework 1.0 and Visual Studio 2002 C# 2 comes in 2005 with .NET framework 2.0 and Visual Studio 2005 C# 3 comes in 2008 with .NET framework 2.0 and Visual Studio 2008 C# 4 comes in 2010 with .NET framework 4.0 and Visual Studio 2010 C# …

C# Versions and Features Read More
C#

C# params

C# params allows you to design a method which accepts variable number of parameters. These parameters are stored in an array and available to called method. static void DoWork(params int[] arr) { if (arr != null) { foreach (var i in arr) { Console.WriteLine(i); } } } There are two ways …

C# params Read More
C#

ref vs out parameters

This post is about difference between ref and out parameters. C# provides three keywords when you defining a method signature. These keywords are: params ref out By default, method arguments are passed by value. That means calling method pass a duplicate copy of data to the called method. If called …

ref vs out parameters Read More
C#

C# Generic Methods

In my previous post, I explained about Generics. C# also provides generic methods. We can create a method that defers the parameter data type until the method is called. These parameters are called type parameters, which means we can pass the actual data type later. Below is an example of …

C# Generic Methods Read More
C#

C# Generics

Generics are introduced in C# 2.0. It is the most powerful features of C#. In C# 1.0, when we design a class that use other types that is not known at defining the structure of the class, then type should be an object type. In the class, we have to …

C# Generics Read More