If you need a variable of Type Form to be used in a method you can just cast a type down as long as the class you are casting
inherits from Form or a casting operator has been overridden in either of the Types.
Here's an example of how this may be useful when you have a method that requires some common Type to do work:
public string GiveMeAForm(Form form)
{
// All Form Types (those classes that derive from Form) will have a Text property that they inherit from the Form Type.
return form.Text;
}
public static void Main()
{
// Create a new Form of a Type you have declared
MyForm form = new MyForm();
// There is an implicit cast occuring here since the framework can easily change your MyForm reference into a Form reference
since
// it inherits directly from this class.
Console.WriteLine(GiveMeAForm(form));
}
This is an extremely simple example meant to illustrate one use of inheritance in .NET. This code doesn't actually do anything
useful since in the case of Form you will have access to the Text property without requiring a method, but you can see how casting
can be useful in more complex situations.
You should research object oriented programming (OOP) and techniques, and polymorphism to get a better understanding of inheritance.
--
Dave Sexton
dave@www..jwaonline..com
-----------------------------------------------------------------------
"Cor Ligthert" <no************@planet.nl> wrote in message news:Ov**************@TK2MSFTNGP14.phx.gbl...
vb6dev
Try to forget the form handling from VB6.
It has changed also in VBNet and is for classic VB devellopers probably one of the biggest problems, in VB6 was taken let say a
non OO approach to make RAD easy.
Try to leave that approach, it will only give you problems in future.
See all your different forms as seperated classes that should be handled as every other class.
Just my thought
Cor