Wednesday, June 4, 2014

How to pass the null parameters for the method and pass value for the particular parameter in .Net c#

Introduction

In this article we are going to learn the topic of how to passing the null values for the parameters having the integer and also passing the values to particular parameter using the asp.net c#.

In this code we have one sub() method it having the integer input parameters actually we not able to pass the null values to the integer directly to overcome this we use one ? Key for this to overcome.

Like int? i = null


Coding

New feature in the 4.0





using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            Sub();
            Sub(1, 2, "Hi"true, 0.1);
            Sub(i: 1);
            Sub(j: 2);
            Sub(k: "Hi");
            Sub(b: true);
            Sub(d: 0.1);
        }

        public static void Sub(int? i = nullint? j = nullstring k = nullbool b = falsedouble? d = null)
        {

        }
    }

}




No comments:

Post a Comment