Placing and removing element on array trough object
- by Chris
Hello,
Lets assume i have 2 methods 1 that places a element on the array and one that removes it.
const int Max = 10;
int[] table= new int[Max];
I would like to call it up like this:
s1.Place(5); // 5 0 0 0 0 0 0 0 0 0 0
s1.Place(9); // 5 9 0 0 0 0 0 0 0 0 0
s1.Remove(9); // 5 0 0 0 0 0 0 0 0 0 0
I would only like to use : using system for this.
The result i get right now when i run the program is s1 = "nameofprogram" "name of class object"
Normally i should get 0 0 0 0 0 0 0 0 0 0 to begin with.
Any ideas how i can exactly add or remove those elements on the array?
public void Place(int g)
{
if (top == Max)
{
throw new Exception("Stack overflow...");
}
else
{
table[top] = g;
top++;
}
....
Best Regards.