Last active
February 14, 2024 23:55
-
-
Save ShvedAction/b78114b40cf3a6bf228ce1c7e45a4a6a to your computer and use it in GitHub Desktop.
C# Reflection: How to get access to property of anonymous objects.
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
object getProp(object source, string name) | |
{ | |
var type = source.GetType(); | |
var prop = type.GetProperty(name); | |
return prop.GetValue(source); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment