Get string name of property using reflection

If you already have a PropertyInfo, then @dtb’s answer of using PropertyInfo.Name is the right way. If, however, you’re wanting to find out which property’s code you’re currently in, you’ll have to traverse the current call stack to find out which method you’re currently executing and derive the property name from there. var stackTrace = … Read more

Reflection – get attribute name and value on property

Use typeof(Book).GetProperties() to get an array of PropertyInfo instances. Then use GetCustomAttributes() on each PropertyInfo to see if any of them have the Author Attribute type. If they do, you can get the name of the property from the property info and the attribute values from the attribute. Something along these lines to scan a … Read more

Setting a property by reflection with a string value

You can use Convert.ChangeType() – It allows you to use runtime information on any IConvertible type to change representation formats. Not all conversions are possible, though, and you may need to write special case logic if you want to support conversions from types that are not IConvertible. The corresponding code (without exception handling or special … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)