I have a class
public class Car
{
public string Name {get;set;}
public int Year {get;set;}
}
In a separate code, I have the field name as a string (let it use "Year") as an example.
I want to do something like this
if (Car.HasProperty("Year"))
which will determine if there is a Year field on the vehicle object. This will return true.
if (Car.HasProperty("Model"))
will return false.
I see code to scroll through properties, but would like to see if there is a more concise way to determine if one field exists.
leora source
share