Events
Mar 17, 9 PM - Mar 21, 10 AM
Join the meetup series to build scalable AI solutions based on real-world use cases with fellow developers and experts.
Register nowThis browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Specifies that a property or procedure redeclares one or more existing properties or procedures with the same name.
Overloading is the practice of supplying more than one definition for a given property or procedure name in the same scope. Redeclaring a property or procedure with a different signature is sometimes called hiding by signature.
Declaration Context. You can use Overloads
only in a property or procedure declaration statement.
Combined Modifiers. You cannot specify Overloads
together with Shadows in the same procedure declaration.
Required Differences. The signature in this declaration must be different from the signature of every property or procedure that it overloads. The signature comprises the property or procedure name together with the following:
the number of parameters
the order of the parameters
the data types of the parameters
the number of type parameters (for a generic procedure)
the return type (only for a conversion operator procedure)
All overloads must have the same name, but each must differ from all the others in one or more of the preceding respects. This allows the compiler to distinguish which version to use when code calls the property or procedure.
Disallowed Differences. Changing one or more of the following is not valid for overloading a property or procedure, because they are not part of the signature:
whether or not it returns a value (for a procedure)
the data type of the return value (except for a conversion operator)
the names of the parameters or type parameters
the constraints on the type parameters (for a generic procedure)
parameter modifier keywords (such as ByRef
or Optional
)
property or procedure modifier keywords (such as Public
or Shared
)
Optional Modifier. You do not have to use the Overloads
modifier when you are defining multiple overloaded properties or procedures in the same class. However, if you use Overloads
in one of the declarations, you must use it in all of them.
Shadowing and Overloading. Overloads
can also be used to shadow an existing member, or set of overloaded members, in a base class. When you use Overloads
in this way, you declare the property or method with the same name and the same parameter list as the base class member, and you do not supply the Shadows
keyword.
If you use Overrides
, the compiler implicitly adds Overloads
so that your library APIs work with C# more easily.
The Overloads
modifier can be used in these contexts:
.NET feedback
.NET is an open source project. Select a link to provide feedback:
Events
Mar 17, 9 PM - Mar 21, 10 AM
Join the meetup series to build scalable AI solutions based on real-world use cases with fellow developers and experts.
Register now