|
-
September 12th, 2007, 10:09 AM
#1
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
-
September 12th, 2007, 08:53 PM
#2
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
-
September 12th, 2007, 08:58 PM
#3
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
-
September 12th, 2007, 11:42 PM
#4
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);
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|