Why Only One Parent In Inheritance
Mar 2, 2011What's the choice design that microsoft do that? Of course, as of me, I don't use inheritance a lot, or at all.
View 14 RepliesWhat's the choice design that microsoft do that? Of course, as of me, I don't use inheritance a lot, or at all.
View 14 RepliesI am learning inheritance in VB.Net. A homework assignment asks me to write a base class with a name (String) property and a ToString method that displays the name. It also asks me to create some child classes of the base class and also implement a ToString method in those child classes. Is it possible for me to call the ToString method from both the child and base class?
[Code]...
Again, I am wondering if there is a way to call the ToString() method within the child class and then base class to generate output something like: "Hello VB.Net This is the name"
This is a challenging one that got me stumped while I was coding today. Suppose I am running the Sub Test1() and Test2() and would like to print out the value of the Shadows method of the instance of the object I am passing in to TestCall() (see below - it is clearer) using the following restrictions:
Can't change the contents of Class A, B, and C
Can't change Sub Test1() and Sub Test2()
TestCall() can't have an if, select case etc. statement that tries to figure out the type
[code].....
I have a main form, and some sub forms, and each sub form can have some sub forms. When I have multiple sub forms open, and I try to get data from the parent form, it returns the data from the wrong parent form.For example I have two instances of Mainform.subform running. If I do something like this in a child form of one instance of the subform. It returns data from the other subform.
dim l = Mainform.subform.listofdata
Edit:I am using visual Studio 2008. Winforms, form designed using designer. In my mainform I am doing this
Protected Friend frmMain as Mainform
frmmain = new mainform
In frmMain I am doing this
Protected Friend frmsub as new Subform'
frmsub = new subform
[code]....
I would like to know if there is some simple code to release a child control from it's parent control, without having to name the parent control. In pseudocode, I'm looking for something like this:
[Code]...
I have a listview "CategoriesList" and i have a repeater "NewsRepeater" inside the listview "CategoriesList"
<asp:ListView ID="CategoriesList" runat="server" DataKeyNames="CatID" DataSourceID="CategoriesListODS"
EnableModelValidation="True">
[Code]....
how to pass the catID from the listview and make it as SelectParameters in ObjectDataSource "NewsRepeaterODS"?
i am just trying to apply inheritance ..Below is my Code ... on which i am not getting the output on my Text_Box ... when in write it in a Child Class
Imports System
Imports System.Windows
Imports System.Windows.Forms
[code]....
Has someone a hint what I'm doing wrong in VB.Net?
Module Module1
Interface ISearch(Of T As ISearchResult)
Function ids() As List(Of T)
End Interface
[CODE]...
The third cast isn't working. Why? did I miss a oop lesson?
we have 3 classes:Class S, class A, class B / A and B inherits S.A has a property A1 and B has a property B1.we also have a collection of objects that has A and B objects.ex.
Dim c as Collection = new Collection
c.add(new A)
c.add(new B)
Now we want to make a general object that will read from the collection.
ex .
Dim obj as S
how can we cast obj in order to see properties A1 or B1 according to the class;
Form1
Public Class Form1
Private Sub But_Bell_Click(sender As System.Object, e As System.EventArgs) Handles But_Bell.Click
MessageBox.Show("Ding a ling")
End Sub
[code]....
Where has the whistle button gone? The class part of the inheritance has works because you can access it via code.
Why VB.NET (vs C#) does not "inherit" the constructors with parameters?
Public Class StopLine
Inherits Microsoft.VisualBasic.PowerPacks.LineShape
Public Sub New()
MyBase.New()
[code]....
I'm facing a problem regarding multiple inheritance in VB.net:As far as I know VB.net does not support multiple inheritance in general but you can reach a kind of multiple inheritance by working with interfaces (using "Implements" instead of "Inherits"):
Public Class ClassName
Implements BaseInterface1, BaseInterface2
End Class
That works fine for classes but I'd like to have an interface inheriting some base interfaces. Something like that:
[Code]...
What are the situations and their associated benefits of using Generics over Inheritance and vice-versa, and how should they be best combined?I'm going to try to state the motivation for this question as best I can:I have a class as shown below:
[Code]...
Now suppose I have a repository that takes an InformationReturn argument, that has to strore different fields in a DB depending on the type of Info object T is. Is it better to create different repositories each for the type T is; one repository that uses reflection to determine the type; or is there a better way using inheritance capabilities over/with generics?
I have a base class ("MyBaseClass") in a project called "BaseFramework" which is included in several solutions within the company. There are several derived class's in various projects throughout the company that inherit from "MyBaseClass". If I then create a List and add derived class's to it, it will not serialize. I realise that if I were attempting to serialize this list, and the base class and derived class were in the same project, I could simply apply the "XmlInclude" attribute to the base class and include all of the derived class's. This is however not possible across projects, because that would require a circular dependency.
View 1 RepliesI searched quickly and not find an explicit answer at the following question:Why VB.NET (vs C#) does not "inherit" the constructors with parameters?
Public Class StopLine
Inherits Microsoft.VisualBasic.PowerPacks.LineShape
Public Sub New()
[code].....
How can I convert following code to VB.NET?
class A
{
public int NumberA { get; set; }
}
[code]....
In VB.NET there is problem with Implements keyword after property declaration. So I need to do something like this:
Class B
Inherits A
Implements IC
[code]....
But there is duplicit misleading property NumberA1.
I have the following code; now i set a propertygrid.selectedobject to the Square object, and start changing the Squares properties. If i change the [Position.x] or [position.y] values in the propertygrid the [Position] and [center] properties update correctly, however when i change the [Center] property, neither [Position] or [Position.x] or [Position.y] update. Is there something else i must do to get this to work both ways. Maybe something is lacking in PointFConverter?
Imports System
Imports System.Collections
Imports System.Drawing
[code]....
Suppose I want to inherit from System.Data.SqlClient.SqlTransaction which is sealed. Supose I want to just put a wrapper around SqlTransaction and always use MyTransaction instead of SqlTransaction. Is there a way I could potentially cast MyTransaction to SqlTransaction using an Implicit/Widening operator?
View 8 RepliesI have a parent class and many children class, right now it look like this:
Public Class Parent
Public Property ID as String
End Class
[Code].....
What I need is a strongly type list List(Of Child) that Inherits from ListOfParent (I need the FindByID method) but I can't find the right syntax.
get around lack of multiple inheritance
View 2 RepliesI am currently working on a framework for applications developed by my company, my boss wants to have a switchboard and a MenuStrip, where the entries and their actions are controlled by a database.
Now I've dealt with all the code to get them working. But the problem that I am facing is that I have duplicated code because each of the classes have the code that deals with ensuring the user has the right privileges and the code to deal with when a user clicks on an item.
Normally I would move this code out into a class and then have each of the classes inherit from the class, but because the switchboard already inherits from the Form class and the customised MenuStrip inherits from the MenuStrip class.After doing some Googling the only answer I have been able to find it using an interface for the functionality, which is obviously not exactly what I want.
Anyway I was just wondering whether any one had any suggestions on what I could do to deal with this problem, as I would like to avoid having duplicate code as much as possible.
I have a library of graphical controls used to display values from a remote device. The controls are typically graphical objects such as a digital meter, analog meter, vertical bar, etc. I first create these controls with a value property. The control will display the value property, e.g. the meter needle will move to the position representing the value.
The next thing I do is to create a new control that inherits the previous discussed control. The new control adds properties that allows the value to be set from values retreived through a communication component. My code that does this is 99% the same for all of the controls. Since I already inherit the graphical control, I can not inherit the class that retreives the values from the communication component.
[Code]....
I was wondering if it is possible to have dependent types in VB.Net 4, or alternatively, if it is possible to construct inherited objects based on the base class' constructor's parameter(s). For example,
[Code]...
I'm writing some code in VB.Net which I hope demonstrate to colleagues (not to say familiarise myself a little more) with various design patterns - and I'm having an issue with the FactoryMethod Pattern.
[Code]...
working on an implementation of a list control for a card game. The catch is the deck control object. I want it to be reusable for different types of cards, which is wheretuck since I seem to be having some issues.First: The basic card object
Public Class BaseCard
'Properties
Private _Id As Integer
[code]....
I have two Forms, which have similar Functionality (i.e. an amount of similar Controls) but complete different Layout. So the normal inheritedForm (which VS2010 provides) wont work here.
I have tried following:
Public Class BaseForm
Inherits System.Windows.Forms.Form
Friend WithEvents Button1 As System.Windows.Forms.Button
[Code].....
So it looks like, the Designer only tries to guess how the Form looks like by inspecting the top-most Class, without compiling the full inheritance-Tree...
I would like to create an user control that has a panel and a button. The user control should set font color, size, font type, and other properties but when I place the user control on a form I would like to be able to modify the text for the button.
View 5 RepliesI am rather new to OOP and I have, what may be, a simple question. I am developing an architecture for a project that includes some object inheritence trees. I have been running into a bunch of narrowing conversion issues (the old 'Unable to cast object of type x to x' error). I understand the limitations of narrowing conversions and why this error exists, but I'm not quite sure how to get around it architecturally. Here is an analogous problem to mine...
[Code]...
I have a base object, with a event that can be triggered by multiple methods.Then I created a child object that inherits that base object. I want to be able to trigger that event in the new object; but I can't use RaiseEvent to raise a base-object's event.To get around this, I created a small method in the base object that takes the argument for the event and I just use it to trigger the event. Is this the proper way to handle this situation? Similarly, I could Shadow the event with a duplicate one in the child object.Is there a standard way to handle events across inheritance?
View 2 RepliesI've not played with inheritance myself much as I've never really had a need to, but now I have a situation which to me seems the ideal time to learn. I'll explain:
This is a WPF application but that shouldnt make any difference to this question. Basically, I have asearch window that retrieves data from a database - I want this one search window to be able to retrieve any item (business object might be a better word than item) from the database and display the relevant data, rather than having a separate window for each 'type' of item in my program. So I have got 3 classes at the moment, ComputerAudit, ConnectionAudit, and SoftwareAudit and I want my one search window to be able to display any of these items in the listbox. Obviously there would only be one type of item displayed at once, so there wouldnt be a computeraudit item and a connectionaudit item displayed in the list at the same time, but there could be several computeraudit items displayed.
So I thought I could create a base class just named Audit and have those 3 classes I mentioned inherit from that, then I can specify the arguments to methods I am using as just being of type Audit (rather than using a specific type like ComputerAudit or SoftwareAudit) because then I should be able to pass around any of these items which inherit from Audit right? Well that doesnt seem to be the case so I'm wondering if I have misunderstood inheritance.
The problem I'm having specifically is that I have some methods which need to be able to accept any of my Audit subclasses but if I specify a generic List(Of Audit) then it wont let me pass in a List(Of ComputerAudit) for example. Is this because I'm using a List or am I just doing something fundamentally wrong?
EDIT: Found this page which confirms my suspicions that this is more to do with the List than general inheritance:[URL]...