-
Reflection
Hi I am using reflection and I need to get the properties out of my type
But I only want to get the properties that have both Get and Set Accessors.
How can I accomplish that using the BindingFlags enum?
Here is my code:
Code:
foreach (Type type in assembly.GetTypes())
{
foreach (PropertyInfo propInfo in type.GetProperties(BindingFlags.SetProperty | BindingFlags.GetProperty))
{
//do some stuff here.
}
}
This does not quite work. I need to go inside the second loop only if the specific Property has both Get and Set.
Thanks very much in advance
Susan
-
Re: Reflection
hm....it sounds like it's a tough topic.
Does anyone know at least a good reference where I can find information on Reflection?
I have checked out MSDN already.
Thanks
Susan
-
Re: Reflection
hi,
not too sure about your question, but i would highly recommend that wonderful site known as google :P seriously, just google 'reflection tutorial' or 'reflection whatever' and something will come up.
god bless the almighty power of google :P :)
good luck! :)
adam
-
Re: Reflection
Try this:
Code:
foreach (Type type in assembly.GetTypes())
foreach (PropertyInfo propInfo in type.GetProperties())
if (propInfo.CanRead && propInfo.CanWrite)
Console.WriteLine(propInfo.Name);