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

What happens when we Box...

Câu trả lời

Here's an explanation of what happens when you box or unbox nullable types in C#:

Boxing Nullable Types

When you box a nullable type, the following happens:

  1. If the nullable type has a value (i.e., it's not null), the value is boxed into an object. This means a new object is created on the heap that contains the value of the nullable type.

  2. If the nullable type is null, boxing it results in a null reference.

Unboxing Nullable Types

When you unbox a nullable type, the following happens:

  1. If the boxed object contains a value that is compatible with the target nullable type, the value is unboxed into the nullable type.

  2. If the boxed object is null, unboxing it results in a null value for the nullable type.

  3. If the boxed object contains a value that is not compatible with the target nullable type, an In...

senior

senior

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

middle

What is scope of a Internal member variable of a C# class?

middle

What is difference between constant and readonly ?

senior

What interface should your data structure implement to make the Where method work?

Bình luận

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

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