dimanche 3 mai 2015

Get property's name by PropertyInfo

I have a class like this:

public abstract class SomeClass<T> where T: new() {
    ...
    public void GetData() {
        ...
        var cur = new T();
        var properties = typeof (T).GetProperties(BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly).ToList();
    ...
    }
}

where T can be something like

public class {
    ...
    public int SomeField {get; set;}
    ...
}

How can i get "SomeField" by properties?

If i call properties[i].Name i get "Int32".

There is RuntimePropertyInfo member in property, but i have no access to it.





Aucun commentaire:

Enregistrer un commentaire