|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Inherited form Name from Baseis inheriting from? In my case I am looking for a way to get the name of a form from its base. For example Public Class BaseForm Public Overridable Sub Foo() 'Can I Get the name of the calling obect in here without passing it? End Sub End Class Public Class InheritedForm Inherits BaseForm Public Overrides Sub Foo() mybase.Foo() End Sub End Class ScottL wrote:
> Is there any way to get the name of an inheriting object in the item it Debug.Writeline( Me.Name ) ' "calling" class> is inheriting from? > Public Class BaseForm > Public Overridable Sub Foo() > ' Name of the calling object? Debug.Writeline( MyClass.Name ) ' /this/ class > End Sub HTH,> End Class > > Public Class InheritedForm > Inherits BaseForm > > Public Overrides Sub Foo() > MyBase.Foo() > End Sub > End Class Phill W. I can think of some ugly ways to do it.
One way would be a mustoverride function GetChildName as string That way the inheriting class would have to define a function or property if you prefer to return its name and the base could safely call GetChildName inside Foo. You could do the same with an interface if you chose. I don't know of a quick and easy key word way to do it in VB.NET Show quoteHide quote "ScottL" <scott.loo***@gmail.com> wrote in message news:1166467068.123859.258150@j72g2000cwa.googlegroups.com... > Is there any way to get the name of an inheriting object in the item it > is inheriting from? In my case I am looking for a way to get the name > of a form from its base. > > For example > > Public Class BaseForm > Public Overridable Sub Foo() > 'Can I Get the name of the calling obect in here without > passing it? > End Sub > End Class > > Public Class InheritedForm > Inherits BaseForm > > Public Overrides Sub Foo() > mybase.Foo() > End Sub > End Class >
business layer, data access layer , presentation layer for asp.net using C#.net
Convert OEM to Unicode Validation Controls What is the return type of Session("Something")? class types in vb.net Reflection and SetValue .arrrrggggggghhhhh How to manage a exception in a Aplications Questions, questions...... How do I find the computer name on which my program is running? Lock a .dll |
|||||||||||||||||||||||