vendredi 22 juin 2018

Getting static properties using reflection

I created a class:

public class MyClass
{

  public String Id
  {
    get { return "ID"; }
  }

  public String Name
  {
    get { return "NAME"; }
  }

  public static string Static1 = "STATIC1";
  public static string Static2 = "STATIC2";
}

and when I try to get all properties (statics included) I only get the properties Id and Name.

The code to get properties:

typeof(MyClass).GetProperties(BindingFlags.Public | BindingFlags.Static)

Should I use another BindingFlags?





Aucun commentaire:

Enregistrer un commentaire