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());
using System;
ReplyDeleteusing 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 ?
parse is used when the return type is an integer
Delete