标签:
interface ICompressible { void Compress(); void Decompress(); } interface ILoggedCompressible : ICompressible { void LogSavedBytes(); } public class Document : ILoggedCompressible { // 实现ICompressible public void Compress(){ …} public void Decompress() { …} // 实现ILoggedCompressible public void LogSavedBytes() { …} // 要实现所有的接口成员
as operator
foreach (Document doc in folder) { IStorable isDoc = doc as IStorable; if (isDoc != null) { isDoc.Read(); }else{ Console.WriteLine("IStorable not supported");doc.Encrypt(); } … } as 有左右两个操作数 Casts the left operand to the type specified by the right operand. Returns null if the cast fails.
标签:
原文地址:http://www.cnblogs.com/GSONG/p/4399062.html