以下の内容はhttps://baba-s.hatenablog.com/entry/2022/09/27/090236より取得しました。


【C#】基底クラスを継承しているもしくはインターフェイスを実装している場合 true を返す拡張メソッド

概要

/// <summary>
/// 指定された基底クラスを継承しているもしくはインターフェイスを実装している場合 true を返します
/// </summary>
public static bool IsInherits( this Type self, Type baseOrInterfaceType )
{
    if ( self == null ) return false;
    if ( baseOrInterfaceType == null ) return self.IsInterface || self == typeof( object );
    if ( baseOrInterfaceType.IsInterface ) return self.GetInterfaces().Contains( baseOrInterfaceType );

    var currentType = self;

    while ( currentType != null )
    {
        if ( currentType.BaseType == baseOrInterfaceType ) return true;
        currentType = currentType.BaseType;
    }

    return false;
}

参考サイト様




以上の内容はhttps://baba-s.hatenablog.com/entry/2022/09/27/090236より取得しました。
このページはhttp://font.textar.tv/のウェブフォントを使用してます

不具合報告/要望等はこちらへお願いします。
モバイルやる夫Viewer Ver0.14