I am trying to cast an object array to generic object array in CSharp, keep getting this compiler error. Any ideas?
Thanks
private const int INITIAL_CAPACITY = 20;
protected int numElements;
protected E[] elements;
/*
* default constructor that creates a new set
* that is initially empty
* */
public ArraySet()
{
numElements = 0;
elements = (E[])(new Object[INITIAL_CAPACITY]);// unchecked
}
thanks guys, Another related question, I want to set a particular element to null. The following code does not work.
elements[numElements - 1] = null:
What is the correct null value we should use in here then. thank