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

In how many ways you can pass parameters to a method?

Câu trả lời

There are several ways to pass parameters to a method in C#:

  1. By Value: This is the default method of passing parameters in C#. When you pass a parameter by value, a copy of the parameter's value is passed to the method. Any changes made to the parameter inside the method do not affect the original value outside the method.

  2. By Reference: To pass a parameter by reference, you need to use the ref keyword. When you pass a parameter by reference, you pass a reference to the original variable, not a copy of its value. Any changes made to the parameter inside the method will affect the original variable outside the method.

  3. Using Output Parameters: Output parameters are used to return multiple values from a method. To use output parameters, you need to use the out keyword. Output parameters are similar to reference parameters, but they do not require the variable to be initialized before passing it to the method.

  4. Using Optional Parameters: Optional parameters allow you to specify default value...

junior

junior

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

middle

What is Virtual Method in C#?

senior

Can you explain the difference between Interface , abstract class, sealed class, static class and
partial class in C#?

junior

What is Boxing and Unboxing?

Bình luận

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

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