CodeTypeDeclaration.TypeAttributes 屬性

定義

取得或設定型別的屬性。

public:
 property System::Reflection::TypeAttributes TypeAttributes { System::Reflection::TypeAttributes get(); void set(System::Reflection::TypeAttributes value); };
public System.Reflection.TypeAttributes TypeAttributes { get; set; }
member this.TypeAttributes : System.Reflection.TypeAttributes with get, set
Public Property TypeAttributes As TypeAttributes

屬性值

TypeAttributes 物件,表示型別的屬性。

備註

屬性 TypeAttributes 包含在運行時間調查類型時所使用的 System.Reflection 相同值類型。 其中許多旗標並未對應至某些語言的類型宣告語法。 因此,只有下列旗標對 :、、AbstractSealedNotPublicPublicInterfaceNestedPublic、 和NestedPrivate很重要。 ClassCodeTypeDeclaration

注意

某些旗標,例如Abstract與 繼承自 CodeTypeMemberCodeTypeDeclaration 屬性中的Attributes旗標意義重疊。 屬性Attributes是繼承自 CodeTypeMemberCodeTypeDeclaration類別的副作用,因此類別可以巢狀化。 應該使用 屬性中的 TypeAttributes 旗標,而不是 屬性中的 Attributes 旗標。

注意

設定可見度旗標的模式 (包含單字 PublicNested) 的旗標,是使用 VisibilityMask 遮罩所有可見度旗標,然後設定所需的可見性旗標。 例如,將名為 cd) (識別CodeTypeDeclaration為內部類別的 C# 程式代碼語句為 cd.TypeAttributes = (cd.TypeAttributes & ~TypeAttributes.VisibilityMask) | TypeAttributes.NotPublic;。 在 Visual Basic 中設定相同值的程式代碼為 cd.TypeAttributes = (cd.TypeAttributes And (TypeAttributes.VisibilityMask Xor -1)) Or TypeAttributes.NotPublic。 將 TypeAttributes 屬性直接設定為可見度旗標 (cd.TypeAttributes = TypeAttributes.NotPublic;) 清除可能設定的所有其他旗標。

適用於

另請參閱