Elvis operator in C#

 For Example: Write a program to demonstrate the use of elvis operator.

   class Program

    {

        static void Main(string[] args)

        {

            double? num1 = null;

            double? num2 = 4.44;

            double num3;

 

            num3 = num1 ?? 7.88;

            Console.WriteLine(" Value of num3 is: {0}", num3);

 

            num3 = num2 ?? 7.88;

            Console.WriteLine(" Value of num3 is: {0}", num3);

            Console.ReadLine();

        }

    }

Output:

Comments

Popular posts from this blog

simple program C#

Regular Expression Validator Control in asp.net

two dimension array in C#