Skip to content

Instantly share code, notes, and snippets.

@codewings
codewings / ValueSetter.cs
Last active December 19, 2015 12:48
Get/Set the value of a property in arbitrary depth of an object by reflection.
class Reflector
{
public static object SetValue(object target, string path, object value)
{
Stack<PropertyInfo> s1 = new Stack<PropertyInfo>();
Stack<object> s2 = new Stack<object>();
string[] properties = path.Split('.');
Type type = target.GetType();