Support us .Net Basics C# SQL ASP.NET ADO.NET MVC Slides C# Programs Subscribe Buy DVD

Part 6 – Nullable types in C#





1 comment:

  1. using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;

    namespace Sample
    {
    class Program
    {
    static void Main(string[] args)
    {
    string name = "C#";
    Console.WriteLine("hello {0}", name);
    int AvailableTickets;
    Console.WriteLine("Enter Number of Tcikets on sale?");
    int? TicketOnSale = int.Parse(Console.ReadLine());

    if(TicketOnSale==null)
    {
    AvailableTickets = 0;
    }
    else
    {
    AvailableTickets = (int)TicketOnSale;
    }
    Console.WriteLine("AvailableTickets are {0}", AvailableTickets);

    }

    }
    }

    its not returning a null value ?

    ReplyDelete

If you like this website, please share with your friends on facebook and Google+ and recommend us on google using the g+1 button on the top right hand corner.