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:

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:

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:

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

Could you explain the difference between destructor , dispose and finalize method?

middle

What is Virtual Method in C#?

middle

How encapsulation is implemented in C#?

Bình luận

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

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