本文整理汇总了C#中Class.getModifiers方法的典型用法代码示例。如果您正苦于以下问题:C# Class.getModifiers方法的具体用法?C# Class.getModifiers怎么用?C# Class.getModifiers使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Class
的用法示例。
在下文中一共展示了Class.getModifiers方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: IsInstantiable
/// <summary>
/// This is used to determine if the class is an inner class. If
/// the class is a inner class and not static then this returns
/// false. Only static inner classes can be instantiated using
/// reflection as they do not require a "this" argument.
/// </summary>
/// <param name="type">
/// this is the class that is to be evaluated
/// </param>
/// <returns>
/// this returns true if the class is a static inner
/// </returns>
public bool IsInstantiable(Class type) {
int modifiers = type.getModifiers();
if(Modifier.isStatic(modifiers)) {
return true;
}
return !type.isMemberClass();
}
示例2: IsInstantiable
/// <summary>
/// This is used to determine whether the type given is instantiable,
/// that is, this determines if an instance of that type can be
/// created. If the type is an interface or an abstract class then
/// this will return false.
/// </summary>
/// <param name="type">
/// this is the type to check the modifiers of
/// </param>
/// <returns>
/// false if the type is an interface or an abstract class
/// </returns>
public bool IsInstantiable(Class type) {
int modifiers = type.getModifiers();
if(Modifier.isAbstract(modifiers)) {
return false;
}
return !Modifier.isInterface(modifiers);
}