|
-
September 2nd, 2004, 02:24 PM
#1
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.
Nicolas Bohemier
-
September 2nd, 2004, 04:16 PM
#2
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?
-
September 2nd, 2004, 07:56 PM
#3
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.
Good Luck,
Craig - CRG IT Solutions - Microsoft Gold Partner
-My posts after 08/2015 = .NET 4.x and Visual Studio 2015
-My posts after 11/2011 = .NET 4.x and Visual Studio 2012
-My posts after 02/2010 = .NET 4.0 and Visual Studio 2010
-My posts after 12/2007 = .NET 3.5 and Visual Studio 2008
-My posts after 04/2007 = .NET 3.0 and Visual Studio 2005
-My posts before 04/2007 = .NET 1.1/2.0
*I do not follow all threads, so if you have a secondary question, message me.
-
September 2nd, 2004, 11:24 PM
#4
Re: A little interesting comment on VB.Net
in ADA, the return type is part of the signature. Anyway I'll work around that
Nicolas Bohemier
-
September 3rd, 2004, 09:29 AM
#5
Re: A little interesting comment on VB.Net
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
|