Bernard,
In addition to the other comments, you could use one or more Interfaces:
Something like:
Public Interface IFluid
Property Pressure() As Integer
Property Temp() As Integer
Property FlowRate() As Integer
End Interface
Public Class Fluid
Implements IFluid
Private m_flowRate As Integer
Private m_pressure As Integer
Private m_temp As Integer
Public Property FlowRate() As Integer Implements IFluid.FlowRate
Get
Return m_flowRate
End Get
Set(ByVal value As Integer)
m_flowRate = value
End Set
End Property
Public Property Pressure() As Integer Implements IFluid.Pressure
Get
Return m_pressure
End Get
Set(ByVal value As Integer)
m_pressure = value
End Set
End Property
Public Property Temp() As Integer Implements IFluid.Temp
Get
Return m_temp
End Get
Set(ByVal value As Integer)
m_temp = value
End Set
End Property
End Class
Public Interface IDrop
Property Diameter() As Integer
Property Temp() As Integer
Property Pressure() As Integer
End Interface
Public Class Drop
Implements IDrop
Private m_diameter As Integer
Private m_pressure As Integer
Private m_temp As Integer
Public Property Diameter() As Integer Implements IDrop.Diameter
Get
Return m_diameter
End Get
Set(ByVal value As Integer)
m_diameter = value
End Set
End Property
Public Property Pressure() As Integer Implements IDrop.Pressure
Get
Return m_pressure
End Get
Set(ByVal value As Integer)
m_pressure = value
End Set
End Property
Public Property Temp() As Integer Implements IDrop.Temp
Get
Return m_temp
End Get
Set(ByVal value As Integer)
m_temp = value
End Set
End Property
End Class
Public Interface ISection
Inherits IFluid
Inherits IDrop
End Interface
Public Class Section
Implements ISection
Private m_flowRate As Integer
Private m_pressure As Integer
Private m_temp As Integer
Private m_diameter As Integer
Public Property FlowRate() As Integer Implements IFluid.FlowRate
Get
Return m_flowRate
End Get
Set(ByVal value As Integer)
m_flowRate = value
End Set
End Property
Public Property Pressure() As Integer Implements IFluid.Pressure ,
IDrop.Pressure
Get
Return m_pressure
End Get
Set(ByVal value As Integer)
m_pressure = value
End Set
End Property
Public Property Temp() As Integer Implements IFluid.Temp, IDrop.Temp
Get
Return m_temp
End Get
Set(ByVal value As Integer)
m_temp = value
End Set
End Property
Public Property Diameter() As Integer Implements IDrop.Diameter
Get
Return m_diameter
End Get
Set(ByVal value As Integer)
m_diameter = value
End Set
End Property
End Class
Then rather then define your parameters as the class, you would define them
as the Interface.
For Example:
Public Shared Sub ProcessFluid(By Val aFluid As IFluid)
Debug.WriteLine (CObj(aFluid).G etType().Name)
Debug.Indent()
Debug.WriteLine (aFluid.Pressur e, "Fluid.Pressure ")
Debug.WriteLine (aFluid.Temp, "Fluid.Temp ")
Debug.WriteLine (aFluid.FlowRat e, "Fluid.FlowRate ")
Debug.Unindent( )
End Sub
Public Shared Sub ProcessDrop(ByV al aDrop As IDrop)
Debug.WriteLine (CObj(aFluid).G etType().Name)
Debug.Indent()
Debug.WriteLine (aDrop.Diameter , "Drop.Diameter" )
Debug.WriteLine (aDrop.Temp, "Drop.Diameter" )
Debug.WriteLine (aDrop.Pressure , "Drop.Pressure" )
Debug.Unindent( )
End Sub
Public Shared Sub Main()
Dim aFluid As New Fluid
Dim aDrop As New Drop
Dim aSection As New Section
ProcessFluid(aF luid)
ProcessFluid(aS ection)
ProcessDrop(aDr op)
ProcessDrop(aSe ction)
End Sub
Note you don't need to use three actual interface, you can get by with only
defining Fluid or Drop in terms on an interface, then Section could inherit
from the other & implement the interface. The key is to use the Interface
instead of the class when you want to accept a Section in addition to the
class... Section could also implement ISection by using delegation to actual
Fluid & Drop objects...
Hope this helps
Jay
"Bernard Bourée" <be*****@bouree .net> wrote in message
news:ek******** ******@TK2MSFTN GP15.phx.gbl...
Well if I try to make it simple
I have one class named FLUID which contains various properties like
Pressure
Temp
FlowRate
An other class named DROP which contains properties like
Diameter
Temp
Pressure
And a last one called SECTION which should contains the properties of
FLUID,
DROP plus some others.
So the solution I have now is to make a copy of the FLUID's properties
inside SECTION
But If I have to change the properties of FLUID I have to remind to do it
in
both places.
Thank for your help
--
Bernard Bourée
be*****@bouree. net
"Larry Serflaten" <se*******@usin ternet.com> a écrit dans le message de
news:%2******** ********@tk2msf tngp13.phx.gbl. ..
"Bernard Bourée" <be*****@bouree .net> wrote > Is there a way to overpass the impossibility of VN.NET to accept the multi > heritage, that is to allow a class to inherit from TWO mother classes ?
If there was a often used need for multiple inheritance, then MS would
have probably found a way to include it. Evidently they decided there wasn't
an absolute need that would be common enough for the functionality.
Perhaps if you describe what you want to do, someone can explain how
to do that within the confines of the language you are using....
LFS