Thursday, 15 October 2015

Null Coalescing Operator (??) in C#

Program Using Null Coalescing Operator ??
using System;
class Program
{
    public static void Main()
    {
        int AvailableChocolate;

        int? ChocolateForSale = null;

        AvailableChocolate = ChocolateForSale ?? 0;

        Console.WriteLine("Available Chocolate = {0}", AvailableChocolate);
    }
}

No comments:

Post a Comment