vendredi 4 novembre 2016

How to iterate all static public Guids in static classc [duplicate]

This question already has an answer here:

Given is my sample class:

public static class MyConstantClass
{
    public static readonly Guid Prop1 = new Guid("d0f6f396-b75e-4312-bb54-09fbb40cf51e");
    public static readonly Guid Prop2 = new Guid("398810e5-1ed2-468c-9f21-1af58dcecbbf");
}

what i have tried so far:

var props= typeof(MyConstantClass).GetProperties(BindingFlags.Public |
                                                 BindingFlags.Static | 
                                                 BindingFlags.FlattenHierarchy)
                                  .ToList();

But this returns an empty list.





Aucun commentaire:

Enregistrer un commentaire