Support us .Net Basics C# SQL ASP.NET Aarvi MVC Slides C# Programs Subscribe Download

Part 6 – Nullable types in C#





2 comments:

  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
    Replies
    1. parse is used when the return type is an integer

      Delete

It would be great if you can help share these free resources