
- C# Basic Tutorial
- C# - Home
- C# - Overview
- C# - Environment
- C# - Program Structure
- C# - Basic Syntax
- C# - Data Types
- C# - Type Conversion
- C# - Variables
- C# - Constants
- C# - Operators
- C# - Decision Making
- C# - Loops
- C# - Encapsulation
- C# - Methods
- C# - Nullables
- C# - Arrays
- C# - Strings
- C# - Structure
- C# - Enums
- C# - Classes
- C# - Inheritance
- C# - Polymorphism
- C# - Operator Overloading
- C# - Interfaces
- C# - Namespaces
- C# - Preprocessor Directives
- C# - Regular Expressions
- C# - Exception Handling
- C# - File I/O
- C# Advanced Tutorial
- C# - Attributes
- C# - Reflection
- C# - Properties
- C# - Indexers
- C# - Delegates
- C# - Events
- C# - Collections
- C# - Generics
- C# - Anonymous Methods
- C# - Unsafe Codes
- C# - Multithreading
- C# Useful Resources
- C# - Questions and Answers
- C# - Quick Guide
- C# - Useful Resources
- C# - Discussion
What are the different ways for a method to be overloaded in C#?
The different ways with which a method can be overloaded is −
The datatypes of parameters are different The number of parameters are different
The following gives an example stating different datatypes of parameters −
void print(int i) { Console.WriteLine("Printing int: {0}", i ); } void print(double f) { Console.WriteLine("Printing float: {0}" , f); } void print(string s) { Console.WriteLine("Printing string: {0}", s); }
The following states the different number of parameters −
// two parameters public static int mulDisplay(int one, int two) { return one * two; } // three parameters public static int mulDisplay(int one, int two, int three) { return one * two * three; } // four parameters public static int mulDisplay(int one, int two, int three, int four) { return one * two * three * four; }
- Related Articles
- What are overloaded indexers in C#?
- Overloaded method and ambiguity in C#
- What are the different ways the transaction can be executed(DBMS)?
- Can main() be overloaded in C++?
- Different ways to overload a method in Java
- What are the different ways to install pandas?
- Functions that can’t be overloaded in C++
- Operators that cannot be overloaded in C++
- Functions that cannot be overloaded in C++
- What are different types of parameters to a method in C#?
- Different ways for Integer to String Conversions in C#
- What are the different ways to implement dependency injection and their advantages in C#?
- What are the different ways of cooking eggs?
- Different ways to start a Task in C#
- What are the different ways to include dry fruits in our diet?

Advertisements