현재 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