I have a class with static members.
I want to get a list of all the static members that their class is defined in the namespace “foo” and inherit from class “bar”
something like list x= typeof(this).staticmembers.where(namespace == "foo");
TRY1:
var AllowedTypes = GetType().Assembly.GetTypes()
.Where(x => x.Namespace == "XX.XXX.XXX")
.Where(x => x.IsAssignableFrom(typeof(UserControl)));
var StaticMembersOfAllowedTypes = typeof(MainWindowXX).GetMembers (System.Reflection.BindingFlags.Static ).Where(item => AllowedTypes.Contains(item));
this gives me a list of member infos, but I want the items themselves.
so I can do foreach item compare to another item.
I think this will do the trick. It’s possible there’s some typos, I couldn’t test it
You may need to add
BindingFlags.Public: