|
-
Nov 8th, 2004, 12:48 PM
#1
inherit or implements?
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
Code:
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??
-
Nov 8th, 2004, 12:51 PM
#2
Re: inherit or implements?
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
Code:
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
-
Nov 8th, 2004, 12:58 PM
#3
Frenzied Member
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.
-
Nov 8th, 2004, 01:01 PM
#4
so it is the same thing as an empty New sub in VB.NET then right?
-
Nov 8th, 2004, 01:12 PM
#5
Frenzied Member
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.
-
Nov 8th, 2004, 01:15 PM
#6
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:
Code:
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)
{
}
}
-
Nov 8th, 2004, 01:37 PM
#7
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
VB Code:
Public Sub New(ByVal ID as Integer)
me.New()
'some other code here
End Sub
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|