PasswordPropertyTextAttribute 类

定义

指示对象的文本表示形式被星号等字符遮盖。 无法继承此类。

public ref class PasswordPropertyTextAttribute sealed : Attribute
[System.AttributeUsage(System.AttributeTargets.All)]
public sealed class PasswordPropertyTextAttribute : Attribute
[<System.AttributeUsage(System.AttributeTargets.All)>]
type PasswordPropertyTextAttribute = class
    inherit Attribute
Public NotInheritable Class PasswordPropertyTextAttribute
Inherits Attribute
继承
PasswordPropertyTextAttribute
属性

示例

下面的代码示例演示如何使用 PasswordPropertyTextAttribute 遮盖控件中 PropertyGrid 字符串属性的值。 有关完整代码列表,请参阅如何:在Windows Forms控件中应用属性

// This property exists only to demonstrate the
// PasswordPropertyText attribute. When this control
// is attached to a PropertyGrid control, the returned
// string will be displayed with obscuring characters
// such as asterisks. This property has no other effect.
[Category("Security")]
[Description("Demonstrates PasswordPropertyTextAttribute.")]
[PasswordPropertyText(true)]
public string Password => "This is a demo password.";
' This property exists only to demonstrate the 
' PasswordPropertyText attribute. When this control 
' is attached to a PropertyGrid control, the returned 
' string will be displayed with obscuring characters
' such as asterisks. This property has no other effect.
<Category("Security"), _
Description("Demonstrates PasswordPropertyTextAttribute."), _
PasswordPropertyText(True)> _
Public ReadOnly Property Password() As String
    Get
        Return "This is a demo password."
    End Get
End Property

注解

PasswordPropertyTextAttribute如果该属性放置在属性或类型上,则属性窗口中的文本表示形式显示为点或星号以指示密码字段。

注意

此指示绝不表示任何类型的加密或安全性。 有关使用属性的详细信息,请参阅 “属性”。

构造函数

名称 说明
PasswordPropertyTextAttribute()

初始化 PasswordPropertyTextAttribute 类的新实例。

PasswordPropertyTextAttribute(Boolean)

初始化类的新实例 PasswordPropertyTextAttribute ,可以选择显示密码文本。

字段

名称 说明
Default

指定 . 的 PasswordPropertyTextAttribute默认值。

No

指定文本属性不用作密码。 此 static 字段(Shared 在 Visual Basic 中)是只读的。

Yes

指定文本属性用作密码。 此 static 字段(Shared 在 Visual Basic 中)是只读的。

属性

名称 说明
Password

获取一个值,该值指示定义的属性 PasswordPropertyTextAttribute 是否应显示为密码文本。

TypeId

在派生类中实现时,获取此 Attribute的唯一标识符。

(继承自 Attribute)

方法

名称 说明
Equals(Object)

确定两个 PasswordPropertyTextAttribute 实例是否相等。

GetHashCode()

返回此实例的哈希代码。

GetType()

获取当前实例的 Type

(继承自 Object)
IsDefaultAttribute()

返回指示此实例的值是否为默认值。

Match(Object)

在派生类中重写时,返回一个值,该值指示此实例是否等于指定对象。

(继承自 Attribute)
MemberwiseClone()

创建当前 Object的浅表副本。

(继承自 Object)
ToString()

返回一个表示当前对象的字符串。

(继承自 Object)

显式接口实现

名称 说明
_Attribute.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr)

将一组名称映射为对应的一组调度标识符。

(继承自 Attribute)
_Attribute.GetTypeInfo(UInt32, UInt32, IntPtr)

检索对象的类型信息,该信息可用于获取接口的类型信息。

(继承自 Attribute)
_Attribute.GetTypeInfoCount(UInt32)

检索对象提供的类型信息接口的数量(0 或 1)。

(继承自 Attribute)
_Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)

提供对对象公开的属性和方法的访问。

(继承自 Attribute)

适用于