Alex Rivera | Logout

Is casting to an interface a boxing conversion?

Asked 2010-06-23T13:14:21.923
14

I have an interface IEntity

public interface IEntity{
    bool Validate();
}

And I have a class Employee which implements this interface

public class Employee : IEntity{
    public bool Validate(){ return true; }
}

Now if I have the following code

Employee emp1 = new Employee();
IEntity ent1 = (IEntity)emp1; // Is this a boxing conversion?

If it is not a boxing conversion then how does the cast work?

Edit
Report

1 Answer

0

Boxing means converting a value type to object. You are converting a reference type to another reference type, so this is not a boxing conversion.

answered 2010-06-23T13:17:23.523

Your Answer