Question: I want to add elements to my array through a user input.
I know this can be done very easy using a list but i have to use an array.

The problem with the code is that the array.lenght will always be 1. 
I want the array to have the same size as the total amount of elements in it, so
size of the array shouldnt be set when declaring the array.

I thought that if you add an element to an array it will copy the previous values + the added value and create a new array.

UPDATED WITH ANSWER

```
  public static void Add(int x){

     if (Item == null)  // First time need to initialize your variable
     {
         Item = new int[1];
     }
     else
     {
         Array.Resize<int>(ref Item, Item.Length + 1);
     }
     Item[Item.Length-1] = x; //fixed Item.Length -> Item.Length-1
 }

```

Answer: 
I didn't test in VS. Here you go:

```
namespace ConsoleApplication1
{
    class Program
    {
        static int[] Item; //Fixed int Item[] to int[] Item
        static void Main(string[] args)
        {
            Add(3);
            Add(4);
            Add(6);
        }

     public static void Add(int x){

         if (Item == null)  // First time need to initialize your variable
         {
             Item = new int[1];
         }
         else
         {
             Array.Resize<int>(ref Item, Item.Length + 1);
         }
         Item[Item.Length-1] = x; //fixed Item.Length -> Item.Length-1
     }

    }
}

```

This should resize your array by one each time and then set the last item to what you are trying to add. Note that this is VERY inefficient.
Lists grow as you add elements to it. Arrays have a constant size. If you must use arrays, the easiest way to do it, is to create an array that is big enough to hold the entered elements.

```
private int[] _items = new int[100];
private int _count;

public void Add(int x)
{
    _items[_count++] = x;
}

```

You also need to keep track of the number of elements already inserted (I used the field `_count` here);

---

As an example, you can then enumerate all the items like this:

```
for (int i = 0; i < _count; i++) {
    Console.WriteLine(_items[i]);
}

```

---

You can make the items accessible publicly like this:

```
public int[] Items { get { return _items; } }

public int Count  { get { return _count; } }

```

---

**UPDATE**

If you want to grow the array size automatically, this is best done by doubling the actual size, when the array becomes too small. It's a good compromise between speed and memory efficiency (this is how lists work internally).

```
private int[] _items = new int[8];
private int _count;

public void Add(int x)
{
   if (_count == _items.Lengh) {
       Array.Resize(ref _items, 2 * _items.Length);
   }
    _items[_count++] = x;
}

```

However, keep in mind that this changes the array reference. So no permanent copy of this array reference should be stored anywhere else.