public static object GetPropValue(object src, string propName)
{
return src.GetType().GetProperty(propName).GetValue(src, null);
}
Of course, you will want to add validation and whatnot, but that is the gist of it.
More Related Contents:
- How to get the list of properties of a class?
- Set object property using reflection
- How can I evaluate C# code dynamically?
- Get name of property as a string
- Dynamically Add C# Properties at Runtime
- Get properties in order of declaration using reflection
- Setting/getting the class properties by string name [duplicate]
- How to check whether an object has certain method/property?
- How Can I add properties to a class on runtime in C#?
- How to get current property name via reflection?
- How to set value of property where there is no setter
- How can I get the value of a string property via Reflection?
- C# Reflection and Getting Properties
- Can I set a property value with Reflection?
- Get all inherited classes of an abstract class [duplicate]
- Read the value of an attribute of a method
- Auto-implemented getters and setters vs. public fields
- How to implement a read only property
- AddEventHandler using reflection
- Instantiating a constructor with parameters in an internal class with reflection
- How to get the value of private field using reflection?
- How to hide an inherited property in a class without modifying the inherited class (base class)?
- Dynamic Lang. Runtime vs Reflection
- How to hide public methods from IntelliSense
- How to find out if a property is an auto-implemented property with reflection?
- How to check all properties of an object whether null or empty?
- Create object instance of a class from its name in string variable
- C# 3.0 Auto-Properties – Is it possible to add custom behaviour?
- IsAssignableFrom() returns false when it should return true
- Run a method before all methods of a class