Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Override custom method in subclass
Message
De
08/09/2009 08:23:46
 
 
À
08/09/2009 08:07:51
Information générale
Forum:
ASP.NET
Catégorie:
Programmation orienté objet
Divers
Thread ID:
01423040
Message ID:
01423042
Vues:
73
>Hi. i am coming from vfp backgroup and new in .net. i am trying to subclass a simplebutton or textbox control of .net framework and make my own class. i want to put then my own textbox /button on the form. i was able to create subclass but cant figure out few other things. lets say i have a custom method on my texbox class to activate popup dialog box if certain key is pressed. in my base textbox class, I have a code in textbox's keypress event to call this custom method.
>
>now after adding mytextbox class to my windows form, i want to be able to change something in that custom method. i.e. call base class's method first and then add few lines of my code. how can i do that?
>
>
>thanks for help in advance

Like this ?
	public class One
	{
		public void Something()
		{
			Console.WriteLine("one");
		}
	}
	public class Two : One
	{
		public new void Something() 
		{
			base.Something(); // call base class' method
			Console.WriteLine("two"); // do something else
		}
	}
Gregory
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform