Just curious what anyone else thinks....
I would like all of my class libraries to share a common set of custom
properties and methods, however I don't want to have to recode all of
these properties and methods in each subclass. This is a feature that
MSFT obviously ackknowleges the benefit of since every class in the .NET
framework inherits from the System.Object yet fail to give us access to
a "Root" type object so all of our classes can inherit from
one place. 8 1444
Gene,
What's stopping you from creating your own base class and then deriving
all of your classes from that? They don't stop you from doing that in any
way.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"Gene Vital" <no********@msnew.com> wrote in message
news:ed**************@TK2MSFTNGP09.phx.gbl... Just curious what anyone else thinks.... I would like all of my class libraries to share a common set of custom properties and methods, however I don't want to have to recode all of these properties and methods in each subclass. This is a feature that MSFT obviously ackknowleges the benefit of since every class in the .NET framework inherits from the System.Object yet fail to give us access to a "Root" type object so all of our classes can inherit from one place.
Gene Vital <no********@msnew.com> wrote: Just curious what anyone else thinks....
I would like all of my class libraries to share a common set of custom properties and methods, however I don't want to have to recode all of these properties and methods in each subclass. This is a feature that MSFT obviously ackknowleges the benefit of since every class in the .NET framework inherits from the System.Object yet fail to give us access to a "Root" type object so all of our classes can inherit from one place.
You don't need Microsoft to give you a class to derive all your other
classes from - you can just create your own one.
--
Jon Skeet - <sk***@pobox.com> http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Jon Skeet [C# MVP] wrote: Gene Vital <no********@msnew.com> wrote:
Just curious what anyone else thinks....
I would like all of my class libraries to share a common set of custom properties and methods, however I don't want to have to recode all of these properties and methods in each subclass. This is a feature that MSFT obviously ackknowleges the benefit of since every class in the .NET framework inherits from the System.Object yet fail to give us access to a "Root" type object so all of our classes can inherit from one place.
You don't need Microsoft to give you a class to derive all your other classes from - you can just create your own one.
I can see how I can do this with non GUI classes but how about GUI
classes like a TextBox or even a Form for that matter??
Gene,
An object is an object is an object. They are all objects, no one
object is more special than the other. You can derive from a form, or a
control, the same rules apply. You just have to make sure you set the
accessibility correctly (protected) for controls/fields/properties you want
a subclass to access, as well as virtual functions/properties which you want
to be able to be overridden.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"Gene Vital" <no********@msnew.com> wrote in message
news:O%******************@TK2MSFTNGP10.phx.gbl... Jon Skeet [C# MVP] wrote: Gene Vital <no********@msnew.com> wrote:
Just curious what anyone else thinks....
I would like all of my class libraries to share a common set of custom properties and methods, however I don't want to have to recode all of these properties and methods in each subclass. This is a feature that MSFT obviously ackknowleges the benefit of since every class in the .NET framework inherits from the System.Object yet fail to give us access to a "Root" type object so all of our classes can inherit from one place.
You don't need Microsoft to give you a class to derive all your other classes from - you can just create your own one.
I can see how I can do this with non GUI classes but how about GUI classes like a TextBox or even a Form for that matter??
Gene Vital <no********@msnew.com> wrote: You don't need Microsoft to give you a class to derive all your other classes from - you can just create your own one.
I can see how I can do this with non GUI classes but how about GUI classes like a TextBox or even a Form for that matter??
You can't do it at that stage. What you *can* do is have a common
interface which has a method to fetch an object which contains all the
properties you need. Then although you'll need a certain amount of code
in each class, it won't be a lot - just the method and a variable to
store the reference to the object it returns.
--
Jon Skeet - <sk***@pobox.com> http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nicholas Paldino [.NET/C# MVP] <mv*@spam.guard.caspershouse.com> wrote: An object is an object is an object. They are all objects, no one object is more special than the other. You can derive from a form, or a control, the same rules apply. You just have to make sure you set the accessibility correctly (protected) for controls/fields/properties you want a subclass to access, as well as virtual functions/properties which you want to be able to be overridden.
I suspect that what Gene means is that if he's already deriving from
Form, or from TextBox, he can't *also* derive from another "root"
class.
--
Jon Skeet - <sk***@pobox.com> http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nicholas Paldino [.NET/C# MVP] wrote: Gene,
An object is an object is an object. They are all objects, no one object is more special than the other. You can derive from a form, or a control, the same rules apply. You just have to make sure you set the accessibility correctly (protected) for controls/fields/properties you want a subclass to access, as well as virtual functions/properties which you want to be able to be overridden.
I understand all of that, my point is that there is no single point
that I can create for ALL subclasses to inherit from.
If I want to add a property to a Form and a TextBox I have to add the
code to my Form subclass and my Textbox subclass repeating the same
identical code in both places. Or are you telling me that I can create a
Form subclass and a Textbox subclass that both inherit from the same
base class? If so then I am missing it somewhere.
Gene,
I understand now, and unfortunately, you can't do that. MS can do it,
like you said, but then again, they own the code. However, I can't see them
making a change to something like object (at least, not the public face of
it), but something like Control, definitely.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"Gene Vital" <no********@msnew.com> wrote in message
news:Oj**************@TK2MSFTNGP14.phx.gbl... Nicholas Paldino [.NET/C# MVP] wrote: Gene,
An object is an object is an object. They are all objects, no one object is more special than the other. You can derive from a form, or a control, the same rules apply. You just have to make sure you set the accessibility correctly (protected) for controls/fields/properties you want a subclass to access, as well as virtual functions/properties which you want to be able to be overridden.
I understand all of that, my point is that there is no single point that I can create for ALL subclasses to inherit from.
If I want to add a property to a Form and a TextBox I have to add the code to my Form subclass and my Textbox subclass repeating the same identical code in both places. Or are you telling me that I can create a Form subclass and a Textbox subclass that both inherit from the same base class? If so then I am missing it somewhere. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: monkey king |
last post by:
I have a given dll file(PDFCreator.dll) - probably generated by VC++.
I want to use its method(PDFCreator()) in dotNet environment. It works
well in WindiowsApplication, but bad in WebApplication...
|
by: muralidharan |
last post by:
WebForm1.aspx Code:
<%@ Register TagPrefix="ComponentArt" Namespace="ComponentArt.Web.UI"
Assembly="ComponentArt.Web.UI" %> <ComponentArt:TreeView
id="TreeView1" Height="520"...
|
by: Vitling |
last post by:
For no apparent reason, a NullReference exception is thrown in
system.dll
(System.Net.Sockets.OverlappedAsyncResult.CompletionPortCallback).
Since I only get a disassembly from Visual Studio, it...
|
by: Raed Sawalha |
last post by:
i have a windows form(Main) with listview, when click an item in listview i
open other window form (Sub) which generate the selected item from parent
window in as treeview items when click any item...
|
by: DOTNET |
last post by:
Hi,
Anybody help me regarding this error:
I am assigning the values to the session variables when the button is
clicked and passing these session variables to the next page and when I am...
|
by: Chuck |
last post by:
I created a VB.net app that opens a current excel workbook, puts some
data in it and saves it.
This works fine on all XP machines. But I am getting an error on win
98 machines.
here a portion...
|
by: Ryan |
last post by:
Hi,
I receive an access denied error (see below) when attempting to send an
email with BodyFormat=MailFormat.Html from an asp.net page. Exactly the same
code works fine in a console...
|
by: forest demon |
last post by:
for example, let's say I do something like,
System.Diagnostics.Process.Start("notepad.exe","sample.txt");
if the user does a SaveAs (in notepad), how can i capture the path that
the user...
|
by: =?Utf-8?B?TmF0aGFuIFdpZWdtYW4=?= |
last post by:
Hi,
I am wondering why the .NET Framework is quite different from Win32 API when
it comes to displaying system modal message boxes.
Consider the four following types of system modal message...
|
by: sdanda |
last post by:
Hai i am working on vb.net.
In my application I created four forms.Those are first.vb,f1.vb,f2.vb and f3.vb
In firstvb I added 3 checkboxes and a "display" button.The 3 checkboxes are used to...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |