Structs, Interfaces and Boxing

Posted by Sekhat on Stack Overflow See other posts from Stack Overflow or by Sekhat
Published on 2010-06-13T15:26:26Z Indexed on 2010/06/13 15:32 UTC
Read the original article Hit count: 249

Filed under:
|
|
|

Take this code:

interface ISomeInterface
{
    public int SomeProperty { get; }
}

struct SomeStruct : ISomeInterface
{
    int someValue;

    public int SomeProperty { get { return someValue; } }

    public SomeStruct(int value)
    {
        someValue = value;
    }
}

and then I do this somewhere:

ISomeInterface someVariable = new SomeStruct(2);

is the SomeStruct boxed in this case?

© Stack Overflow or respective owner

Related posts about c#

Related posts about interfaces