using System;
public class NoDescException : ApplicationException
{
public NoDescException() { }
public NoDescException(string message) : base(message) { }
public NoDescException(string message, Exception innerEx)
: base(message, innerEx) { }
}
public interface IFun1
{ string ShowMe();}
public interface IFun2
{ string ShowMe(); }
class Circle : IFun1
{
public string ShowMe()
{ return "Circle-IFun1"; }
}
public class ObjShowMe
{
public static void ShowMe(object obj)
{
if (!(obj is IFun1 && obj is IFun2))
{
throw new NoDescException("Interface not implemented for " + obj.ToString());
}
}
}
public class MyApp
{
static void Main()
{
Circle myCir = new Circle();
try
{
ObjShowMe.ShowMe(myCir);
}
catch (NoDescException ex)
{
Console.WriteLine(ex.Message);
}
}
}
已有 22658 名学员学习以下课程通过考试
最需教育客户端 软件问题一手掌握
去 App Store 免费下载 iOS 客户端
点击加载更多评论>>