Reflection - PropertyInfo

Z

Zanna

Hi all!

A little question on System.Reflection.

I know that with the MethodInfo I can get if a method is public or private.

But for properties?
PropertyInfo does not contain a IsPublic property!

How can I get this information for a property?

Thanx
 
J

Jon Skeet

Zanna said:
A little question on System.Reflection.

I know that with the MethodInfo I can get if a method is public or private.

But for properties?
PropertyInfo does not contain a IsPublic property!

How can I get this information for a property?

Retrieve each of the methods associated with the property and find out
if it's public or not. Note that in the next version of .NET properties
will be able to have (say) a public accessor and a private mutator.
 
Z

Zanna

Jon Skeet said:
Retrieve each of the methods associated with the property and find out
if it's public or not.

I don't understand how can I say if a property is public using this.
Can you do an example?

If a method is public for a property you cannot say if the property itself
is public or not (always if the property has methods to explore).

Thanx
 
J

Jon Skeet

Zanna said:
I don't understand how can I say if a property is public using this.
Can you do an example?

If a method is public for a property you cannot say if the property itself
is public or not (always if the property has methods to explore).

Not at all sure by what you meant by the bits in brackets, but I
believe a property really *is* effectively public if and only if it has
a public accessor or mutator. Can you give an example where this isn't
true?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top