static string name = "Test";
public static void Main()
GetPropertyValue(name, "value");
public static object GetPropertyValue(object obj, string propertyName)
var _propertyNames = propertyName.Split('.');
for (var i = 0; i < _propertyNames.Length; i++)
var _propertyInfo = obj.GetType().GetProperty(_propertyNames[i]);
if (_propertyInfo != null)
obj = _propertyInfo.GetValue(obj);