System.ArgumentNullException: 'Value cannot be null. (Parameter 's')'
I am getting this error ^.
I want to make it so after I press CTRL Z on the product code it will stop the loop and proceed to the next lines of code. BUT I put in ctrl z and it goes to the Quantity line and breaks after that. If anyone knows how to fix this error, I think its because the Quantity cant return a Null value since its not setup like product is but I cant find a way around it.
public class Transaction
{
public string Name { get; set; }
public int productCode { get; set; }
public int productQuantity { get; set; }
//constructor
public Transaction(string cName)//, int pCode, int pQuantity
{
Name = cName;
}
public void AssessProducts()
{
int codeInput;
int qtyInput = 0;
decimal transTotal = 0;
double qty201 = 0;
double qty556 = 0;
double count201 = 0;
double count556 = 0;
double count558 = 0;
double count909 = 0;
double count910 = 0;
Console.WriteLine("Product Code: ");
string ctrlzInput = Console.ReadLine();
Console.WriteLine("Quantity: ");
qtyInput = int.Parse(Console.ReadLine());
while (ctrlzInput != null)
{
codeInput = int.Parse(ctrlzInput);
if (codeInput == 201)
{
count201 = count201 + 19.99;
}
else if (codeInput == 556)
{
count556 = count556 + 59.99;
}
else if (codeInput == 558)
{
count558 = count558 + 20.50;
}
else if (codeInput == 909)
{
count909 = count909 + 105.99;
}
else if (codeInput == 910)
{
count910 = count910 + 16.99;
}
else
{
Console.WriteLine("Error! Wrong product code.");
}
transTotal = (decimal)((double)transTotal + count201 + count556 + count558 + count909 + count910);
qty201 = qty201 + qtyInput;
qty556 = qty556 + qtyInput;
Console.WriteLine("Product Code: ");
ctrlzInput = Console.ReadLine();
Console.WriteLine("Quantity: ");
qtyInput = int.Parse(Console.ReadLine());
}
Console.WriteLine($"Customer Name: {Name} \n\n");
Console.WriteLine("Items Ordered:\n\n");
Console.WriteLine("Product # Product Name Price Qty Line Total\n");
if (count201 >= 1)
{
Console.Write($"Product 210 - ACME Anvil @ $19.99 *{qty201} = {qty201 * 19.99} \n");
}
if (count556 >= 1)
Console.Write($"Product 556 - ACME Dynamite @ $59.99 *{qty556} = {qty556 * 59.99} \n");
}
}

