I posted early about Hashtable use and the shallow/deep copy and storing a
reference answered that question.
I've got a larger implementation of this, but am not sure why I'm getting
this error. Object reference not set to an instance of an object. I don't
know what I'm missing. What needs to be fixed for this implementation to
work?
using System;
using System.Collections;
public class SamplesHashtable
{
static Hashtable HT = new Hashtable();
public static Q[] qrec = new Q[2];
public static void Main()
{
qrec[0].symbol = "HI";
qrec[0].price = 4.0;
HT.Add("First", qrec[0]);
qrec[1].symbol = "BYE";
qrec[1].price = 5.0;
HT.Add("Second", qrec[1]);
qrec[0] = (Q)HT["First"];
qrec[0].price = qrec[0].price - 1.0;
}
public class Q
{
public string symbol;
public double price;
}
}