What happens when we Box...
What happens when we Box...
Here's an explanation of what happens when you box or unbox nullable types in C#:
When you box a nullable type, the following happens:
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.
If the nullable type is null, boxing it results in a null reference.
When you unbox a nullable type, the following happens:
If the boxed object contains a value that is compatible with the target nullable type, the value is unboxed into the nullable type.
If the boxed object is null, unboxing it results in a null value for the nullable type.
If the boxed object contains a value that is not compatible with the target nullable type, an In...
senior
Gợi ý câu hỏi phỏng vấn
Chưa có bình luận nào