Created
September 20, 2019 15:13
-
-
Save Sergio0694/5bc8cc99ca7d536af081fa089673d17d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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