Changing Access specifier

P

Paul Cheetham

Hi,

I am creating a custom control in c#, derived from System.Drawing.Image

In my derived control, I want to make the Public property Image into a
Protected property, as I only want to manipulate it from within the
class.

In C++ this would be as simple as re-declaring it with the new access
specifier (protected) but it doesn't seem to work in c#

Can anybody help me with this?


Thankyou.


Paul Cheetham
 
N

Nicholas Paldino [.NET/C# MVP]

Paul,

If you wanted to do this, then you would have to declare the property as
new, like so:

protected new Image Image
{
...
}

However, if your control is cast to a reference of type Control, and the
Image property is set, it will call the original implementation, not your
new one.

Hope this helps.
 

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