Although I don’t know exactly about its implementation, I would expect it to use reflection.
Basically you call Type.GetPropertyor Type.GetMethodto get the corresponding member, then ask it about the value of this property for a specific instance (or call a method, etc.). Alternatively there Type.GetMembers, Type.GetMemberetc ..
"Person.Mother.Name" "", , , . ( , API .)
, :
using System;
using System.Reflection;
public class Person
{
public string Name { get; set; }
public int Age { get; set; }
}
class Test
{
static void Main()
{
Person jon = new Person { Name = "Jon", Age = 33 };
ShowProperty(jon, "Name");
ShowProperty(jon, "Age");
}
static void ShowProperty(object target, string propertyName)
{
PropertyInfo property = target.GetType().GetProperty(propertyName);
object value = property.GetValue(target, null);
Console.WriteLine(value);
}
}