How do I cast Class FooObject to class BarObject which both implement interface IObject? [duplicate]
问题 This question already has answers here : Casting between two types derived from the (same) interface (9 answers) Casting between classes that share the same interface (7 answers) Casting a interface derived class to another derived class (1 answer) Closed 10 months ago . I have 2 classes which implement the same interface. But somehow I cannot cast them from one to another. Here's an example: public interface IObject { // ... } public class FooObject : IObject { // ... } public class