Net.Bluewalk.DotNetUtils/Extensions/ObjectExtensions.cs
/// <summary>
/// Get value from object by specified property name
/// </summary>
/// <param name="obj"></param>
/// <param name="property"></param>
/// <typeparam name="T"></typeparam>
/// <returns></returns>
Get value from object by specified property name
Get value from object by specified property name
public static T GetValue<T>(this object obj, string property)
        {
            if (obj == null) return default;
            var prop = obj.GetType().GetProperty(property);
            if (prop == null) return default;
            return (T) prop.GetValue(obj, null);
        }
public static T GetValue < T > ( this object obj , string property ) { if ( obj == null ) return default ; var prop = obj . GetType ( ) . GetProperty ( property ) ; if ( prop == null ) return default ; return ( T ) prop . GetValue ( obj , null ) ; }
Get value from object by specified property name
Get value from object by specified property name
None
object
this
property
string
None
obj
None
typeparam
None