Casting of interfaces

Posted by Srinivas Reddy Thatiparthy on Stack Overflow See other posts from Stack Overflow or by Srinivas Reddy Thatiparthy
Published on 2010-04-12T10:33:40Z Indexed on 2010/04/12 10:43 UTC
Read the original article Hit count: 579

Filed under:
|
|

interfaces provide a useful abstraction capability. One can have a class Foo implement some interfaces, say A, B, and C. Some client code may get a reference of type A, others one of type B, etc. each actually the same Foo object but the interface exposing only a narrow subset of the functionality. Of course, evil client code can try to cast the A reference to Foo, then access the other functionality.How to prevent this?

© Stack Overflow or respective owner

Related posts about c#

Related posts about java