Click to See Complete Forum and Search --> : inherit or implements?
kleinma
Nov 8th, 2004, 11:48 AM
I have some sample code done in C#, but the code I am writing is in VB.NET
the documentation for these DLLs I am using is total crap and gives me next to no information
So the class declare looks like this
public class CImageOrderStatusListener : IOrderStatusListener
{
public CImageOrderStatusListener()
{
}
//MORE CODE HERE
}
since IOrderStatusListener is an interface I would assume in my VB.NET code I would implement it, but the documentation says
"Inner class inherits IOrderStatusListener to listen to the image order status. "
so its a bit confusing, unless its just saying that implementing the interface is interface inheritence...
and why have the empty function with the same name as the class.. is that a C# thing??
axion_sa
Nov 8th, 2004, 11:51 AM
Originally posted by kleinma
I have some sample code done in C#, but the code I am writing is in VB.NET
the documentation for these DLLs I am using is total crap and gives me next to no information
So the class declare looks like this
public class CImageOrderStatusListener : IOrderStatusListener
{
public CImageOrderStatusListener()
{
}
//MORE CODE HERE
}
since IOrderStatusListener is an interface I would assume in my VB.NET code I would implement it, but the documentation says
"Inner class inherits IOrderStatusListener to listen to the image order status. "
so its a bit confusing, unless its just saying that implementing the interface is interface inheritence...
and why have the empty function with the same name as the class.. is that a C# thing??
It's definitely implementing if the the class is an interface (which the I prefix suggests), and the method with the same name (but without a return type) as the class is the constructor :)
[Edit] Got confused between inherit and implement for a moment there :P
Mike Hildner
Nov 8th, 2004, 11:58 AM
and why have the empty function with the same name as the class.. is that a C# thing??
That's the default, no arguments constructor. I don't know about your first question.
kleinma
Nov 8th, 2004, 12:01 PM
so it is the same thing as an empty New sub in VB.NET then right?
Mike Hildner
Nov 8th, 2004, 12:12 PM
I think it's similar, but not exactly - heh, big help I am.
The reason I say similar is because you can freely add args to that constuctor, say in a Windows Forms app and all works fine. When I've tried to do that with VB's sub new, seemed like the form did not get initialized properly. I'm sure it's just my ignorance.
There's also no MyBase.New business in C#, but I'm not versed well enough in the differences between those two languages to tell you what's really happening.
axion_sa
Nov 8th, 2004, 12:15 PM
Originally posted by Mike Hildner
I think it's similar, but not exactly - heh, big help I am.
The reason I say similar is because you can freely add args to that constuctor, say in a Windows Forms app and all works fine. When I've tried to do that with VB's sub new, seemed like the form did not get initialized properly. I'm sure it's just my ignorance.
There's also no MyBase.New business in C#, but I'm not versed well enough in the differences between those two languages to tell you what's really happening.
To get the "MyBase.New" in C#, you would:
public class MyClass: MyParentClass
{
public MyClass(): base() // This is the call to the parent's constructor.
{
// Init code here...
}
// Useless info.
public MyClass(object someParam): this(someParam.ToString()) // This is a call to the overloaded constructor that accepts a string.
{
}
public MyClass(string someParam)
{
}
}
kleinma
Nov 8th, 2004, 12:37 PM
Originally posted by Mike Hildner
I think it's similar, but not exactly - heh, big help I am.
The reason I say similar is because you can freely add args to that constuctor, say in a Windows Forms app and all works fine. When I've tried to do that with VB's sub new, seemed like the form did not get initialized properly. I'm sure it's just my ignorance.
There's also no MyBase.New business in C#, but I'm not versed well enough in the differences between those two languages to tell you what's really happening.
you can do that in VB.NET, you just need to call the New sub that has no arguments in the first line of YOUR new sub that you created...
like
Public Sub New(ByVal ID as Integer)
me.New()
'some other code here
End Sub
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.