Question: I am trying to get buttons (they are numbers) when pressed to show two digits in the label, currentChannelLabel, I created. I have been messing around with this and I can either get one number to show, or I get two of the same number to show. How do I fix my code so I get one number to show, then a second number? After this, if another button is selected, it will show the first number again and then the second. For example:

(button 1 is pressed)
currentChannelLabel: 1
(button 2 is pressed)
currentChannelLabel: 12
(button 3 is pressed)
currentChannelLabel: 3
(button 4 is pressed)
currentChannelLabel: 34

here is my code:

```
 @IBAction func channelNumbers(_ sender: UIButton) {
    var number = ""
    if let pressed = sender.currentTitle {
        number = "\(pressed)"
        currentChannelLabel.text = number
        if let pressed2 = sender.currentTitle{
            number += "\(pressed2)"
            currentChannelLabel.text = number
        }   
    }
}

```

Answer: 
you don't need to resize info\_passengers array since it is enough for total passangers. When you add an extra array cell, you add a passanger to the end of arry, but you still have the empty cells in the beginnig of array with null that are causing the exception.

so remove this code

```
 Array.Resize(ref info_passengers, info_passengers.Length + 1);

```

and fix this

```
 total_passengers++;
 info_passengers[ total_passengers-1] = passenger;

```

and don't forget to remove total\_passengers++; from here

```
 Console.WriteLine("You boarded 1 Passenger." + "\nThere are " + (totalSeats - total_passengers) + " seats left.");

```

and add totalAge=0 in calc\_total\_age

```
public void calc_total_age()
    {
       totalAge=0;
      for (int i = 0; i < total_passengers; i++)
      {
        totalAge += info_passengers[i].age;
      }

```

and it is not a very good idea to hide errors in your catch blok. I would make it

```
catch (Exception e)
    {
      Console.WriteLine("\n Error!!! " + e.Message);
      System.Threading.Thread.Sleep(2000);
      return;
    }

```
The answer to this one is very simple!

You declare:

```
public Passenger[] info_passengers;

```

This actually creates a *pointer* to a `Passenger` array, which (like all pointers) is initially null. It does not create the actual array itself.

When your code comes to call:

```
Array.Resize(ref info_passengers, info_passengers.Length + 1);

```

the method `Resize` expects the array parameter to point to an array. However, `info_passengers` is still null. So you get the exception.

I think all you need to do is to initialise `info_passengers` to an new empty array, like this:

```
public Passenger[] info_passengers = new Passenger[]();

```

and then I think it'll all work.