I have created an array with a predefined length of 2. And I have a method for adding items to the array.
The code for it is:
public void addItem(T item)
{
Array.Resize(ref items, items.Count() + 2);
items[items.Count() - 2] = item;
}
Now, what I want to do is that it first has to check the array size and see if the array is full of not. If the array is full, it should double the size of the array. If its not full then it shouldn't do nothing. So, I'm wondering if I can make this possible with an if statement?
EDIT: Im writing an collection class, thats why I need to check the array