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

expert

What is the volatile keyword used for?

expert

List some different ways for equality check in .NET

senior

What is the best practice to have best performance using Lazy objects?

Bình luận

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

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