Skip to content

Instantly share code, notes, and snippets.

@Sergio0694
Created September 20, 2019 15:13
Show Gist options
  • Save Sergio0694/5bc8cc99ca7d536af081fa089673d17d to your computer and use it in GitHub Desktop.
Save Sergio0694/5bc8cc99ca7d536af081fa089673d17d to your computer and use it in GitHub Desktop.
public static void Main()
{
int[] array = new int[10];
{
int value = 1;
Action<int> action = i => array[i] = value;
foreach (var field in CollectFields(action))
{
// Traverse the parents hierarchy
object target = action.Target;
foreach (var parent in field.Parents)
target = parent.GetValue(target);
Console.WriteLine($"{field.Info.Name}: {field.Info.GetValue(target)}");
// array: System.Int32[]
// value: 1
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment