Why is this:
public class BoolClass
{
public bool Value { get; set; }
}
class Program
{
static void Main(string[] args)
{
BoolClass bc1 = new BoolClass { Value = false };
BoolClass bc2 = bc1;
bc1.Value = true;
}
}
will result in
bc2.Value == true
As bool
is the type of value I would expect bc2.Value == false
if it bc2.Value
does not fit in the cell and is not stored on the heap.
I found this method in Stack Overflow to find out if a value is included
public static bool IsBoxed<T>(T value)
{
return
(typeof(T).IsInterface || typeof(T) == typeof(object)) &&
value != null &&
value.GetType().IsValueType;
}
But he says it's not in the box. I'm a little confused, can someone explain this to me?
source
share