When I call inter.GetMethods(), it gives me a list of methods including all the get and set statements. How can I check whether each item (in a foreach) is a get or set statement.
foreach (MethodInfo meth in inter.GetMethods()) Console.WriteLine(meth.Name);
Not exactly the most elegant, but it works:
You could also use
MethodInfo.IsSpecialName, but that can also pick up on other special cases other than just properties, but if you have a simple class that you can test and see that it works, you can use it instead. I wouldn’t recommend it; I’d rather just use a utility method like I have above:var nonPropertyMethods = typeof(MyType).GetMethods().Where(m => !m.IsSpecialName);