A little interesting comment on VB.Net
Okay I Haven't been using VB.Net for a while... Just since april.
and I thought this language was really object oriented... well
I got some news. It's better than vb6 on this part but not good
enough to my taste.
Return value of a function isn't part of the Function Name so in
a OO point of view
this isn't possible
Code:
Public Function A(ByVal str as string) As int
End Function
Public Function A(ByVal str as string) As long
End Function
Which in a way makes VB .NET OO capability somewhat limited...
Anyway just wanted to let you know for those that didn'T know..
If you have any workaround let me know.
Re: A little interesting comment on VB.Net
I'm not exactly sure what your point is. Are you wanting to define both of those methods at the same time for a given class? If so, that's not possible because the compiler wouldn't know which to call (the have the same signature). Also, why would you want a given method to return two different types?
Re: A little interesting comment on VB.Net
Yeah, I'm not sure this would be the best idea. At some point you have to rely on the compiler to guess which function you really wanted to use. The only way the compiler would know which function to run would be based on a comparison between the return type and the variable type that is waiting for the return. What if there was no variable waiting for a return, or if you used a type that is a base type for both functions.
I know that’s confusing; here is an example:
Code:
Private Function DoSomething() as ListBox
'blah...
End Function
Private Function DoSomething() as ListView
'blah...
End Function
'Now, what would the compiler do in these situations:
DoSomething()
'or
Dim o as Object
o = DoSomething()
'In either case, the compiler would have to guess which function you wanted to execute.
Re: A little interesting comment on VB.Net
in ADA, the return type is part of the signature. Anyway I'll work around that
Re: A little interesting comment on VB.Net