ReadOnlyAttribute.IsReadOnly プロパティ
アセンブリ: System (system.dll 内)

この属性が関連付けられているプロパティが読み取り専用の場合は true。プロパティが読み書き可能の場合は false。

MyProperty が読み取り専用かどうかを確認するコード例を次に示します。最初に、次を実行することによって、MyProperty の属性を取得します。
次に、myAttribute を AttributeCollection にある ReadOnlyAttribute の値に設定し、プロパティが読み取り専用かどうかを確認します。
' Gets the attributes for the property. Dim attributes As AttributeCollection = _ TypeDescriptor.GetProperties(Me)("MyProperty").Attributes ' Checks to see whether the property is read-only. Dim myAttribute As ReadOnlyAttribute = _ CType(attributes(GetType(ReadOnlyAttribute)), ReadOnlyAttribute) If myAttribute.IsReadOnly Then ' Insert code here. End If
// Gets the attributes for the property. AttributeCollection attributes = TypeDescriptor.GetProperties(this)["MyProperty"].Attributes; // Checks to see whether the property is read-only. ReadOnlyAttribute myAttribute = (ReadOnlyAttribute)attributes[typeof(ReadOnlyAttribute)]; if(myAttribute.IsReadOnly) { // Insert code here. }
// Gets the attributes for the property. AttributeCollection^ attributes = TypeDescriptor::GetProperties( this )[ "MyProperty" ]->Attributes; // Checks to see whether the property is read-only. ReadOnlyAttribute^ myAttribute = dynamic_cast<ReadOnlyAttribute^>(attributes[ ReadOnlyAttribute::typeid ]); if ( myAttribute->IsReadOnly ) { // Insert code here. }
// Gets the attributes for the property. AttributeCollection attributes = TypeDescriptor.GetProperties(this). get_Item("MyProperty").get_Attributes(); // Checks to see whether the property is read-only. ReadOnlyAttribute myAttribute = ((ReadOnlyAttribute) (attributes.get_Item(ReadOnlyAttribute.class.ToType()))); if (myAttribute.get_IsReadOnly()) { // Insert code here. }

Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からReadOnlyAttribute.IsReadOnly プロパティを検索する場合は、下記のリンクをクリックしてください。

- ReadOnlyAttribute.IsReadOnly プロパティのページへのリンク