获取由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 送给学长毕业祝福语简短