|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Purpose of Keyword "Overloads"?Hi all,
Im just curious, what is the purpose of the keyword "Overloads" in VB nowadays? I understand conceptually what overloads are and what they do, but im a little puzzled, because if you declare two subs or properties or functions with the same name but different signatures, it seems to overload them without any problem anyway, so why is the keyword there? Does using the keyword just work as some sort of compiler hint or something or ? Cheers! - Arthur Dent. Its just there... a optional use... no big deal if you use it or if you
don't... Vijay Show quoteHide quote "Arthur Dent" <hitchhikersguideto-n***@yahoo.com> wrote in message news:eT1x1kkXGHA.3724@TK2MSFTNGP02.phx.gbl... > Hi all, > > Im just curious, what is the purpose of the keyword "Overloads" in VB > nowadays? > I understand conceptually what overloads are and what they do, but im a > little puzzled, > because if you declare two subs or properties or functions with the same > name but > different signatures, it seems to overload them without any problem > anyway, so why > is the keyword there? > Does using the keyword just work as some sort of compiler hint or > something or ? > > Cheers! > - Arthur Dent. > "Vijay" <vi***@msdiscussions.com> schrieb: IIRC 'Overloads' is not always optional (see documentation).> Its just there... a optional use... no big deal if you use it or if you > don't... -- M S Herfried K. Wagner M V P <URL:http://dotnet.mvps.org/> V B <URL:http://classicvb.org/petition/> Here's a simple example on where teh Overloads keyword is necessary:
Public MustInherit Class Class1 Public MustOverride Sub Method1() Public MustOverride Sub Method1(ByVal x As Integer) Public MustOverride Sub Method1(x as Integer, y as String End Class Public Class Class2 Inherits Class1 Public Overloads Overrides Sub Method1() End Sub Public Overloads Overrides Sub Method1(ByVal x As Integer) End Sub Public Overloads Overrides Sub Method1(ByVal x As Integer, ByVal y As String) End Sub End Class In the "Class2" definition, the "Overloads" keyword is necessary or your code will not compile. Show quoteHide quote "Arthur Dent" wrote: > Hi all, > > Im just curious, what is the purpose of the keyword "Overloads" in VB > nowadays? > I understand conceptually what overloads are and what they do, but im a > little puzzled, > because if you declare two subs or properties or functions with the same > name but > different signatures, it seems to overload them without any problem anyway, > so why > is the keyword there? > Does using the keyword just work as some sort of compiler hint or something > or ? > > Cheers! > - Arthur Dent. > > > |
|||||||||||||||||||||||