Purpose of Keyword "Overloads"?

A

Arthur Dent

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.
 
V

Vijay

Its just there... a optional use... no big deal if you use it or if you
don't...

Vijay
 
H

Herfried K. Wagner [MVP]

Vijay said:
Its just there... a optional use... no big deal if you use it or if you
don't...

IIRC 'Overloads' is not always optional (see documentation).
 
G

Guest

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top