Q:

List adding item

I have a model like this:
class PayPalModel
{
    public class Payment
    {
        public string intent { get; set; }
        public Payer payer { get; set; }
        public List<Transaction> transactions { get; set; }
    }

    public class Payer
    {
        public string payment_method { get; set; }
        public List<Funding_Instruments> funding_instruments { get; set; }
    }

    public class Funding_Instruments
    {
        public Credit_Card credit_card { get; set; }
    }

    public class Credit_Card
    {
        public string number { get; set; }
        public string type { get; set; }
        public int expire_month { get; set; }
        public int expire_year { get; set; }
        public string cvv2 { get; set; }
        public string first_name { get; set; }
        public string last_name { get; set; }
        public Billing_Address billing_address { get; set; }
    }

    public class Billing_Address
    {
        public string line1 { get; set; }
        public string city { get; set; }
        public string state { get; set; }
        public string postal_code { get; set; }
        public string country_code { get; set; }
    }

    public class Transaction
    {
        public Amount amount { get; set; }
        public string description { get; set; }
    }

    public class Amount
    {
        public string total { get; set; }
        public string currency { get; set; }
        public Details details { get; set; }
    }

    public class Details
    {
        public string subtotal { get; set; }
        public string tax { get; set; }
        public string shipping { get; set; }
    }

}

And I am trying to add values to it but I am getting stuck on how to add funding_instruments.
I have tried the following but it won't let me add a new Credit_Card
This is my code:
PayPalWrapper.PayPalModel.Payment payment = new PayPalWrapper.PayPalModel.Payment();

        payment.intent = "sale";
        payment.payer = new PayPalWrapper.PayPalModel.Payer();
        payment.payer.payment_method = "credit_card";

        payment.payer.funding_instruments = new List<PayPalWrapper.PayPalModel.Funding_Instruments>();
        payment.payer.funding_instruments.Add(new PayPalModel.Credit_Card() { first_name = "test" });

But it is giving the error
Error 1 The best overloaded method match for 'System.Collections.Generic.List<PayPalWrapper.PayPalModel.Funding_Instruments>.Add(PayPalWrapper.PayPalModel.Funding_Instruments)' has some invalid arguments

I just cannot work out the syntax for adding a Credit_Card!
Can anyone help please?

A:

That is because you are adding the wrong type... 
You have declared funding_instruments as being List<Funding_Instruments> but trying to add a new Credit_Card. To make it work it should look more like this:
payment.payer.funding_instruments.Add(new PayPalModel.Funding_Instruments 
{ 
    credit_card = new PayPalModel.Credit_Card
    {
        first_name = "test"
    }
});

