TypeAttributes
メンバ
フィールド
- Abstract
-
型が抽象的であることを示します。
- 値
-
- 10進数
- 128
- 16進数
- 00 0080
- 2進数
- 0000 0000 0000 0000 1000 0000
- AnsiClass
-
LPTSTR は ANSI として解釈されます。
- 値
-
- 10進数
- 0
- 16進数
- 00 0000
- 2進数
- 0000 0000 0000 0000 0000 0000
- AutoClass
-
LPTSTR は自動的に解釈されます。
- 値
-
- 10進数
- 131072
- 16進数
- 02 0000
- 2進数
- 0000 0010 0000 0000 0000 0000
- AutoLayout
-
クラス フィールドが共通言語ランタイムによって自動的にレイアウトされることを指定します。
- 値
-
- 10進数
- 0
- 16進数
- 00 0000
- 2進数
- 0000 0000 0000 0000 0000 0000
- BeforeFieldInit
-
型の静的なメソッドを呼び出しても、システムによって型が強制的に初期化されることはないことを指定します。
- 値
-
- 10進数
- 1048576
- 16進数
- 10 0000
- 2進数
- 0001 0000 0000 0000 0000 0000
- Class
-
型がクラスであることを示します。
- 値
-
- 10進数
- 0
- 16進数
- 00 0000
- 2進数
- 0000 0000 0000 0000 0000 0000
- ClassSemanticsMask
-
クラスのセマンティクス情報を指定します。現在のクラスはコンテキスト バインド クラスです (そうでない場合は非バインド クラス)。
- 値
-
- 10進数
- 32
- 16進数
- 00 0020
- 2進数
- 0000 0000 0000 0000 0010 0000
- CustomFormatClass
-
LPSTR は、NotSupportedException のスローを含め、実装に固有の手段で解釈されます。 Microsoft 実装の .NET Framework では使用されません。
- 値
-
- 10進数
- 196608
- 16進数
- 03 0000
- 2進数
- 0000 0011 0000 0000 0000 0000
- CustomFormatMask
-
標準以外のエンコーディング情報を取得し、ネイティブな相互運用性を実現するために使用されます。 2 ビットの値が持つ意味は指定されていません。 Microsoft 実装の .NET Framework では使用されません。
- 値
-
- 10進数
- 12582912
- 16進数
- C0 0000
- 2進数
- 1100 0000 0000 0000 0000 0000
- ExplicitLayout
-
クラス フィールドが指定されたオフセットでレイアウトされることを指定します。
- 値
-
- 10進数
- 16
- 16進数
- 00 0010
- 2進数
- 0000 0000 0000 0000 0001 0000
- HasSecurity
-
型にセキュリティが関連付けられています。
- 値
-
- 10進数
- 262144
- 16進数
- 04 0000
- 2進数
- 0000 0100 0000 0000 0000 0000
- Import
-
クラスまたはインターフェイスが別のモジュールからインポートされることを指定します。
- 値
-
- 10進数
- 4096
- 16進数
- 00 1000
- 2進数
- 0000 0000 0001 0000 0000 0000
- Interface
-
型がインターフェイスであることを示します。
- 値
-
- 10進数
- 32
- 16進数
- 00 0020
- 2進数
- 0000 0000 0000 0000 0020 0000
- LayoutMask
-
クラス レイアウト情報を指定します。
- 値
-
- 10進数
- 240
- 16進数
- 00 0018
- 2進数
- 0000 0000 0000 0000 0001 1000
- NestedAssembly
-
クラスが、アセンブリ参照可能範囲の中にネストしているため、そのアセンブリ内のメソッドだけからアクセスできることを指定します。
- 値
-
- 10進数
- 5
- 16進数
- 00 0005
- 2進数
- 0000 0000 0000 0000 0000 0101
- NestedFamANDAssem
-
クラスがアセンブリおよびファミリの参照可能範囲内でネストしていることを指定します。この結果、そのファミリとアセンブリの積集合にあるメソッドだけからアクセスできます。
- 値
-
- 10進数
- 6
- 16進数
- 00 0006
- 2進数
- 0000 0000 0000 0000 0000 0110
- NestedFamily
-
クラスがファミリ参照可能範囲内にネストしていることを指定します。この結果、そのファミリの独自の型および派生型のメソッドだけからアクセスできます。
- 値
-
- 10進数
- 4
- 16進数
- 00 0004
- 2進数
- 0000 0000 0000 0000 0000 0100
- NestedFamORAssem
-
クラスがファミリまたはアセンブリの参照可能範囲内でネストしていることを指定します。この結果、そのファミリとアセンブリの和集合にあるメソッドだけからアクセスできます。
- 値
-
- 10進数
- 7
- 16進数
- 00 0007
- 2進数
- 0000 0000 0000 0000 0000 0111
- NestedPrivate
-
クラスが、プライベートな参照可能範囲の中にネストしていることを指定します。
- 値
-
- 10進数
- 3
- 16進数
- 00 0003
- 2進数
- 0000 0000 0000 0000 0000 0011
- NestedPublic
-
クラスが、パブリックな参照可能範囲の中でネストしていることを指定します。
- 値
-
- 10進数
- 2
- 16進数
- 00 0002
- 2進数
- 0000 0000 0000 0000 0000 0010
- NotPublic
-
クラスがパブリックでないことを指定します。
- 値
-
- 10進数
- 0
- 16進数
- 00 0000
- 2進数
- 0000 0000 0000 0000 0000 0000
- Public
-
クラスがパブリックであることを指定します。
- 値
-
- 10進数
- 1
- 16進数
- 00 0001
- 2進数
- 0000 0000 0000 0000 0000 0001
- ReservedMask
-
ランタイムで使用するために予約された属性。
- 値
-
- 10進数
- 264192
- 16進数
- 04 0800
- 2進数
- 0000 0100 0000 1000 0000 0000
- RTSpecialName
-
ランタイムは名前のエンコード方式を確認する必要があります。
- 値
-
- 10進数
- 2048
- 16進数
- 00 0800
- 2進数
- 0000 0000 0000 1000 0000 0000
- Sealed
-
クラスが具象クラスで、拡張できないことを指定します。
- 値
-
- 10進数
- 256
- 16進数
- 00 0100
- 2進数
- 0000 0000 0000 0001 0000 0000
- SequentialLayout
-
クラス フィールドが、メタデータに生成された順序で連続的にレイアウトされることを指定します。
- 値
-
- 10進数
- 8
- 16進数
- 00 0008
- 2進数
- 0000 0000 0000 0000 0000 1000
- Serializable
-
クラスをシリアル化できることを指定します。
- 値
-
- 10進数
- 8192
- 16進数
- 00 2000
- 2進数
- 0000 0000 0020 0000 0000 0000
- SpecialName
-
名前で説明するという方法で、クラスが特別であることを指定します。
- 値
-
- 10進数
- 1024
- 16進数
- 00 0400
- 2進数
- 0000 0000 0000 0100 0000 0000
- StringFormatMask
-
ネイティブな相互運用性を得るための文字列情報の取得に使用されます。
- 値
-
- 10進数
- 196608
- 16進数
- 03 0000
- 2進数
- 0000 0011 0000 0000 0000 0000
- UnicodeClass
-
LPTSTR は UNICODE として解釈されます。
- 値
-
- 10進数
- 65536
- 16進数
- 01 0000
- 2進数
- 0000 0001 0000 0000 0000 0000
- VisibilityMask
-
型の参照可能範囲情報を指定します。
- 値
-
- 10進数
- 7
- 16進数
- 00 0007
- 2進数
- 0000 0000 0000 0000 0000 0111
- WindowsRuntime
-
Windows ランタイム タイプを指定します。
- 値
-
- 10進数
- 16384
- 16進数
- 00 4000
- 2進数
- 0000 0000 0100 0000 0000 0000
対応表
  | CodeTypeDeclaration |
---|---|
未設定 | public class |
CustomFormatMask | internal class |
BeforeFieldInit | internal class |
ReservedMask | internal class |
HasSecurity | internal class |
StringFormatMask | internal class |
CustomFormatClass | internal class |
AutoClass | internal class |
UnicodeClass | internal class |
WindowsRuntime | internal class |
Serializable | internal class |
Import | internal class |
RTSpecialName | internal class |
SpecialName | internal class |
Sealed | internal sealed class |
Abstract | internal abstract class |
ClassSemanticsMask | internal interface |
Interface | internal interface |
LayoutMask | internal class |
ExplicitLayout | internal class |
SequentialLayout | internal class |
VisibilityMask | protected internal class |
NestedFamORAssem | protected internal class |
NestedFamANDAssem | internal class |
NestedAssembly | internal class |
NestedFamily | protected class |
NestedPrivate | private class |
NestedPublic | public class |
Public | public class |
NotPublic | internal class |
AutoLayout | internal class |
Class | internal class |
AnsiClass | internal class |
例
次の例の値を取得、AttributesプロパティType、さまざまな種類の数を表すオブジェクトを個々 の属性のフラグが設定されているかどうかを判断します。
using System;
using System.Reflection;
internal struct S
{
public int X;
}
public abstract class Example
{
protected sealed class NestedClass {}
public interface INested {}
public static void Main()
{
// Create an array of types.
Type[] types = { typeof(Example), typeof(NestedClass),
typeof(INested), typeof(S) };
foreach (var t in types)
{
Console.WriteLine("Attributes for type {0}:", t.Name);
TypeAttributes attr = t.Attributes;
// To test for visibility attributes, you must use the visibility mask.
TypeAttributes visibility = attr & TypeAttributes.VisibilityMask;
switch (visibility)
{
case TypeAttributes.NotPublic:
Console.WriteLine(" ...is not public");
break;
case TypeAttributes.Public:
Console.WriteLine(" ...is public");
break;
case TypeAttributes.NestedPublic:
Console.WriteLine(" ...is nested and public");
break;
case TypeAttributes.NestedPrivate:
Console.WriteLine(" ...is nested and private");
break;
case TypeAttributes.NestedFamANDAssem:
Console.WriteLine(" ...is nested, and inheritable only within the assembly" +
"¥n (cannot be declared in C#)");
break;
case TypeAttributes.NestedAssembly:
Console.WriteLine(" ...is nested and internal");
break;
case TypeAttributes.NestedFamily:
Console.WriteLine(" ...is nested and protected");
break;
case TypeAttributes.NestedFamORAssem:
Console.WriteLine(" ...is nested and protected internal");
break;
}
// Use the layout mask to test for layout attributes.
TypeAttributes layout = attr & TypeAttributes.LayoutMask;
switch (layout)
{
case TypeAttributes.AutoLayout:
Console.WriteLine(" ...is AutoLayout");
break;
case TypeAttributes.SequentialLayout:
Console.WriteLine(" ...is SequentialLayout");
break;
case TypeAttributes.ExplicitLayout:
Console.WriteLine(" ...is ExplicitLayout");
break;
}
// Use the class semantics mask to test for class semantics attributes.
TypeAttributes classSemantics = attr & TypeAttributes.ClassSemanticsMask;
switch (classSemantics)
{
case TypeAttributes.Class:
if (t.IsValueType)
{
Console.WriteLine(" ...is a value type");
}
else
{
Console.WriteLine(" ...is a class");
}
break;
case TypeAttributes.Interface:
Console.WriteLine(" ...is an interface");
break;
}
if ((attr & TypeAttributes.Abstract) != 0)
{
Console.WriteLine(" ...is abstract");
}
if ((attr & TypeAttributes.Sealed) != 0)
{
Console.WriteLine(" ...is sealed");
}
Console.WriteLine();
}
}
}
// The example displays the following output:
// Attributes for type Example:
// ...is public
// ...is AutoLayout
// ...is a class
// ...is abstract
// Attributes for type NestedClass:
// ...is nested and protected
// ...is AutoLayout
// ...is a class
// ...is sealed
// Attributes for type INested:
// ...is nested and public
// ...is AutoLayout
// ...is an interface
// ...is abstract
// Attributes for type S:
// ...is not public
// ...is SequentialLayout
// ...is a value type
// ...is sealed
定義
[System.Flags]
[System.Runtime.InteropServices.ComVisible(true)]
[System.Serializable]
public enum TypeAttributes
クラス
#region アセンブリ mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
// C:¥Program Files (x86)¥Reference Assemblies¥Microsoft¥Framework¥.NETFramework¥v4.6.1¥mscorlib.dll
#endregion
using System.Runtime.InteropServices;
namespace System.Reflection
{
//
// 概要:
// 型属性を指定します。
[ComVisible( true )]
[Flags]
public enum TypeAttributes
{
//
// 概要:
// クラスがパブリックでないことを指定します。
NotPublic = 0,
//
// 概要:
// クラス フィールドが共通言語ランタイムによって自動的にレイアウトされることを指定します。
AutoLayout = 0,
//
// 概要:
// 型がクラスであることを示します。
Class = 0,
//
// 概要:
// LPTSTR は ANSI として解釈されます。
AnsiClass = 0,
//
// 概要:
// クラスがパブリックであることを指定します。
Public = 1,
//
// 概要:
// クラスが、パブリックな参照可能範囲の中でネストしていることを指定します。
NestedPublic = 2,
//
// 概要:
// クラスが、プライベートな参照可能範囲の中にネストしていることを指定します。
NestedPrivate = 3,
//
// 概要:
// クラスがファミリ参照可能範囲内にネストしていることを指定します。この結果、そのファミリの独自の型および派生型のメソッドだけからアクセスできます。
NestedFamily = 4,
//
// 概要:
// クラスが、アセンブリ参照可能範囲の中にネストしているため、そのアセンブリ内のメソッドだけからアクセスできることを指定します。
NestedAssembly = 5,
//
// 概要:
// クラスがアセンブリおよびファミリの参照可能範囲内でネストしていることを指定します。この結果、そのファミリとアセンブリの積集合にあるメソッドだけからアクセスできます。
NestedFamANDAssem = 6,
//
// 概要:
// 型の参照可能範囲情報を指定します。
VisibilityMask = 7,
//
// 概要:
// クラスがファミリまたはアセンブリの参照可能範囲内でネストしていることを指定します。この結果、そのファミリとアセンブリの和集合にあるメソッドだけからアクセスできます。
NestedFamORAssem = 7,
//
// 概要:
// クラス フィールドが、メタデータに生成された順序で連続的にレイアウトされることを指定します。
SequentialLayout = 8,
//
// 概要:
// クラス フィールドが指定されたオフセットでレイアウトされることを指定します。
ExplicitLayout = 16,
//
// 概要:
// クラス レイアウト情報を指定します。
LayoutMask = 24,
//
// 概要:
// クラスのセマンティクス情報を指定します。現在のクラスはコンテキスト バインド クラスです (そうでない場合は非バインド クラス)。
ClassSemanticsMask = 32,
//
// 概要:
// 型がインターフェイスであることを示します。
Interface = 32,
//
// 概要:
// 型が抽象的であることを示します。
Abstract = 128,
//
// 概要:
// クラスが具象クラスで、拡張できないことを指定します。
Sealed = 256,
//
// 概要:
// 名前で説明するという方法で、クラスが特別であることを指定します。
SpecialName = 1024,
//
// 概要:
// ランタイムは名前のエンコード方式を確認する必要があります。
RTSpecialName = 2048,
//
// 概要:
// クラスまたはインターフェイスが別のモジュールからインポートされることを指定します。
Import = 4096,
//
// 概要:
// クラスをシリアル化できることを指定します。
Serializable = 8192,
//
// 概要:
// 指定する Windows ランタイム 型です。
WindowsRuntime = 16384,
//
// 概要:
// LPTSTR は UNICODE として解釈されます。
UnicodeClass = 65536,
//
// 概要:
// LPTSTR は自動的に解釈されます。
AutoClass = 131072,
//
// 概要:
// ネイティブな相互運用性を得るための文字列情報の取得に使用されます。
StringFormatMask = 196608,
//
// 概要:
// LPSTR は、いくつかの実装に固有の手段のスローを含むによって解釈される、 System.NotSupportedExceptionです。 マイクロソフトの実装では使用されません、
// .NET Frameworkです。
CustomFormatClass = 196608,
//
// 概要:
// 型にセキュリティが関連付けられています。
HasSecurity = 262144,
//
// 概要:
// ランタイムで使用するために予約された属性。
ReservedMask = 264192,
//
// 概要:
// 型の静的なメソッドを呼び出しても、システムによって型が強制的に初期化されることはないことを指定します。
BeforeFieldInit = 1048576,
//
// 概要:
// 標準以外のエンコーディング情報を取得し、ネイティブな相互運用性を実現するために使用されます。 2 ビットの値が持つ意味は指定されていません。 マイクロソフトの実装では使用されません、
// .NET Frameworkです。
CustomFormatMask = 12582912
}
}