MaskedTextProvider.Replace Method (String, Int32, Int32, MaskedTextResultHint)

Replaces a range of editable characters starting at the specified position with the specified string, and then outputs the removal position and descriptive information.

Namespace:  System.ComponentModel
Assembly:  System (in System.dll)

public bool Replace(
	string input,
	int position,
	out int testPosition,
	out MaskedTextResultHint resultHint
)

Parameters

input
Type: System.String

The String value used to replace the existing editable characters.

position
Type: System.Int32

The zero-based position to search for the first editable character to replace.

testPosition
Type: System.Int32

If successful, the zero-based position in the formatted string where the last character was actually replaced; otherwise, the first position where the operation failed. An output parameter.

resultHint
Type: System.ComponentModel.MaskedTextResultHint

A MaskedTextResultHint that succinctly describes the result of the replacement operation. An output parameter.

Return Value

Type: System.Boolean
true if all the characters were successfully replaced; otherwise, false.

The Replace(String, Int32, Int32, MaskedTextResultHint) method searches for the first editable position at or beyond the specified position, pos. Operating on the assumption that there are enough editable positions after this point, the existing character values are replaced one-by-one with the contents of the replacement string parameter, input.

The following conditions are considered errors. When an error occurs, no replacement occurs and Replace(String, Int32, Int32, MaskedTextResultHint) returns false.

  • The pos parameter is less than zero or greater than the Length of the formatted string.

  • There are not enough editable positions in the formatted string to hold the contents of the replacement string.

  • One of the replacement character values is not valid because it is not printable or does not match its corresponding mask element.

In addition to the return value, this method has two output parameters to supply additional information about the replacement operation.

.NET Framework

Supported in: 4.5.2, 4.5.1, 4.5, 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

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

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft