Returns true if the given object is of the specified type, false otherwise.

Use the is operator to check if obj is of the given type, T.

代码实现

public static partial class _30s 
{
  public static bool IsA<T>(object obj) 
  {
    return obj is T;
  }
}

使用样例

string s = "fooBar";

_30s.IsA<string>(s); // true
_30s.IsA<int>(s); // false