CngKey.HasProperty Method (String, CngPropertyOptions)


The .NET API Reference documentation has a new home. Visit the .NET API Browser on to see the new experience.

Checks to see whether the specified property exists on the key.

Namespace:   System.Security.Cryptography
Assembly:  System.Core (in System.Core.dll)

[SecurityPermissionAttribute(SecurityAction.Demand, UnmanagedCode = true)]
public bool HasProperty(
	string name,
	CngPropertyOptions options


Type: System.String

The property name to check.

Type: System.Security.Cryptography.CngPropertyOptions

A bitwise combination of the enumeration values that specify options for the named property.

Return Value

Type: System.Boolean

true if the specified property is found; otherwise, false.

Exception Condition

name is null.

The options parameter is specifically used to indicate the following:

  • Whether the property is built-in, or custom.

  • Whether the property should be persisted with the key.

These options must match the value that the property was set with, or the property will not be found.

This method operates correctly even if the property is set to false or zero.


for permission to call unmanaged code. Demand value: LinkDemand. Associated enumeration: SecurityPermissionFlag.UnmanagedCode

.NET Framework
Available since 3.5
Return to top