-2

I'm having a difficult time finding an answer for what ? means when played after a type of generic Object.

Here's an example:

public class Car
{
    public string Color { get; set; }
    public int Year { get; set; }
    public List<object> Tire { get; set; }
}

string color = "black";
string condition = "good";
int cost = 250;

var tire = new Object();
tire = (color, condition, cost);

Car car = new Car();
car.Tire.Add(tire);

foreach (var t in car.Tire)
{
    //What does "?" mean here
    var tireColor = t?.GetType().GetProperty("color")?.GetValue(t, null);
    var tireCondition = t?.GetType().GetProperty("condition")?.GetValue(t, null);
    var tireValue = t?.GetType().GetProperty("value")?.GetValue(t, null);
}
KidBilly
  • 3,119
  • 23
  • 30

0 Answers0