获取由C#中的当前Type实现或继承的特定接口
为了获得当前Type实现或继承的特定接口,代码如下-
示例
using System;
public class Demo {
public static void Main() {
Type type = typeof(double);
Type myInterface = type.GetInterface("IFormattable");
Console.WriteLine("Interface = "+myInterface);
}
}输出结果
这将产生以下输出-
Interface = System.IFormattable
示例
让我们看另一个例子-
using System;
public class Demo {
public static void Main() {
Type type = typeof(float);
Type myInterface = type.GetInterface("IFormattable",true);
Console.WriteLine("Interface = "+myInterface);
}
}输出结果
这将产生以下输出-
Interface = System.IFormattable
热门推荐
10 上市仪式文案祝福语简短
11 中式婚礼贺词祝福语简短
12 办结婚喜酒祝福语简短
13 爸爸生日举杯祝福语简短
14 新人结婚简短祝福语大全
15 开业经典祝福语简短
16 结业蛋糕男生祝福语简短
17 高温早安祝福语简短精辟
18 培训送别祝福语简短的话