There is a function I want to implement in C#:
public string getName(object ob)
{
// TODO: if object has "Name" attribute, return "Name".Value, else return null;
}
When I invoke this function,
string result1 = getName(new {Name = "jack", Age = 12}) // result1 = "jack"
string result2 = getName(new {Age = 12}) // result2 = null
I know it's easy to implement in JavaScript or other dynamic languages... I am curious about if it can implement in C#?
getName(new {Name = new MyCustomObject()})?