C#中判断一个类是否实现了某interface

 1using System;
 2using System.Threading;
 3using System.Text;
 4using System.Net;
 5using System.Net.Sockets;
 6using System.IO;
 7using System.Data;
 8using System.Collections;
 9using System.Collections.Specialized;
10using System.Data.Odbc;
11using System.Text.RegularExpressions;
12
13
14public interface IOne
15{
16  string GetOne();
17}

18
19public interface ITwo
20{
21  string GetTwo();
22}

23
24public class One : IOne
25{
26public string GetOne()
27{
28  return "one-getone";
29}

30}

31
32public class OneTwo : IOne, ITwo
33{
34public string GetOne()
35{
36  return "OneTwo-getone";
37}

38
39public string GetTwo()
40{
41  return "OneTwo-GetTwo";
42}

43}

44
45public class Ware
46{
47static void Main(String[] args) {
48  One oo = new One();
49  OneTwo ot = new OneTwo();
50   Console.WriteLine(oo is IOne);
51   Console.WriteLine(oo is ITwo);
52   
53   Console.WriteLine(ot is IOne);
54   Console.WriteLine(ot is ITwo);
55}

56
57        
58}
原文地址:https://www.cnblogs.com/margiex/p/1025112.html