How to use Named Parameters in C# ?

Named Parameters is one of the cool features in C# 4.0 that lets you to call the methods with the parameters with their names .

How to use Named Parameters in C# ?

Below is a sample code snippet demonstrating the usage of the Named Parameters in C#.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AbundantcodeConsole
{

    class Program
    {
        static void Main(string[] args)
        {
            SetData(ID: 1, Name: "ACCODE");
        }
        static public void SetData(string Name , int ID)
        {
            Console.WriteLine(Name + ID);
        }
    }
}
%d bloggers like this: