```
public class SelectedItems
{
    public Item item;
    public int quantity;
    public double subtotal = 0.0;

}

...

Console.Write("Enter the purchased item count :");
int count = Convert.ToInt32(Console.ReadLine());

while (count > 0)
{  
    SelectedItems itm = new SelectedItems();
    Console.WriteLine("Enter the code :");
    itm.item = searchItem(Convert.ToInt32(Console.ReadLine()));

    Console.WriteLine("Enter the quantity :");
    itm.quantity = Convert.ToInt32(Console.Read());
    itm.subtotal = itm.item.unitprice * (Convert.ToDouble(itm.quantity));
}   

```

The exception occurs in last line.