What happens when we Box or Unbox Nullable types?
What happens when we Box or Unbox Nullable types?
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:
Đăng nhập để tham gia thảo luận cùng mọi người.
Chưa có bình luận nào
Hãy là người đầu tiên chia sẻ suy nghĩ của bạn.