ModelMetadata.IsRequired 屬性

定義

取得值,指出是否需要模型值。 這只適用于目前實例代表屬性時。

public:
 abstract property bool IsRequired { bool get(); };
public abstract bool IsRequired { get; }
member this.IsRequired : bool
Public MustOverride ReadOnly Property IsRequired As Boolean

屬性值

備註

如果 true 接著驗證程式會考慮模型值。

根據預設,如果 不存在,則會在 時 true. 加入隱含 System.ComponentModel.DataAnnotations.RequiredAttribute

適用於