This documentation is archived and is not being maintained.

SecureString.SetAt Method

Replaces the existing character at the specified index position with another character.

Namespace:  System.Security
Assembly:  mscorlib (in mscorlib.dll)

[<HandleProcessCorruptedStateExceptionsAttribute>]
member SetAt : 
        index:int * 
        c:char -> unit 

Parameters

index
Type: System.Int32
The index position of an existing character in this secure string
c
Type: System.Char
A character that replaces the existing character.

ExceptionCondition
ObjectDisposedException

This secure string has already been disposed.

InvalidOperationException

This secure string is read-only.

ArgumentOutOfRangeException

index is less than zero, or greater than or equal to the length of this secure string.

CryptographicException

An error occurred while encrypting or decrypting the value of this secure string.

The index is zero-based and the first character in this instance is at index position zero.

The value of the secure string, if any, is decrypted; c is assigned to the specified index position; then the new value is encrypted.

The following code example demonstrates how the AppendChar, InsertAt, RemoveAt, SetAt, and Clear methods affect the value of a SecureString object.

No code example is currently available or this language may not be supported.

.NET Framework

Supported in: 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Show: