In programming, syntax refers to the rules that specify the correct combined sequence of symbols that can be used to form a correctly structured program using a given programming language. Programmers communicate with computers through the correctly structured syntax, semantics and grammar of a programming language.
Overloading refers to the ability to use a single identifier to define multiple methods of a class that differ in their input and output parameters. Overloaded methods are generally used when they conceptually execute the same task but with a slightly different set of parameters. Overloading is a concept used to avoid redundant code where the same method name is used multiple times but with a different set of parameters. The actual method that gets called during runtime is resolved at compile time, thus avoiding runtime errors. Overloading provides code clarity, eliminates complexity, and enhances runtime performance.
Overloading is used in programming languages that enforce type-checking in function calls during compilation. When a method is overloaded, the method chosen will be selected at compile time. This is not the same as virtual functions where the method is defined at runtime.Unlike Java, C# allows operators to be overloaded, in addition to methods, by defining static members using the operator keyword. This feature helps to extend and customize the semantics of operators relevant to user-defined types so that they can be used to manipulate object instances with operators. The overload resolution in C# is the method by which the right function is selected on the basis of arguments passed and the list of candidate function members that have the same name. The different contexts in which the overload resolution is used include:
It is recommended to avoid overloading across inheritance boundaries because it can cause confusion. Overloading can become cumbersome to developers if it is used excessively and with user-defined types as parameters because it can reduce the readability and maintainability of code.
Read More »
Join 138,000+ IT pros on our weekly newsletter
Home | Advertising Info | Write for Us | About | Contact Us
2010 - 2015
Partner Sites :