Câu hỏi phỏng vấn C#
Câu hỏi

What are the different ways...

Câu trả lời

Here are the different ways a method can be overloaded in C#:

Method Overloading by Number of Parameters

You can overload a method by having different numbers of parameters. For example:

csharp Copy
public int Add(int a, int b) { return a + b; }
public int Add(int a, int b, int c) { return a + b + c; }

Method Overloading by Type of Parameters

You can overload a method by having parameters of different data types. For example:

csharp Copy
public int Add(int a, int b) { return a + b; } 
public double Add(double a, double b) { return a + b; }

Method Overloading by Order of Parameters

You can overload a method by having the parameters in a different order. For example:

csharp Copy
public int Multiply(int a, int b) { return a * b; }
public int Multiply(int b,...
senior

senior

Gợi ý câu hỏi phỏng vấn

middle

What are the uses of using in C#

junior

What are the different types of classes in C#?

expert

Explain when to use Finalize vs Dispose ?

Bình luận

Chưa có bình luận nào

Chưa có bình luận nào