Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Extending a native property
Message
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Divers
Thread ID:
00859555
Message ID:
00859699
Vues:
11
Properties are really just glorified methods so yes you can override them assuming the base is marked as virtual. You can use the override or new keywords depending on your situation and then call base.

In fact if you type:

override and pick Visible on a Web control you get this implementation automatically:
		public override bool Visible
		{
			get
			{
				return base.Visible;
			}
			set
			{
				base.Visible = value;
			}
		}
Note you can override properties but not fields.

+++ Rick ---

>What is the syntax to use to extend a property in a derived class?
>
>Specifically, I want to execute some additional code in response to the setting of the Visible property on a control, and I want it encapsulated in the control class rather than being handled by a delegate on the form.
>
>I know that I can set up a handler for VisibleChanged, but I'm curious as to whether there is a way of overriding and extending the get/set code of the native property.
>
>Thanks.
+++ Rick ---

West Wind Technologies
Maui, Hawaii

west-wind.com/
West Wind Message Board
Rick's Web Log
Markdown Monster
---
Making waves on the Web

Where do you want to surf today?
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform