Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
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;
}Advertisements