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

Replaces a single character between the specified starting and ending positions with the specified character value, and then outputs the removal position and descriptive information.

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

public bool Replace(
	char input,
	int startPosition,
	int endPosition,
	out int testPosition,
	out MaskedTextResultHint resultHint
)

Parameters

input
Type: System.Char

The Char value that replaces the existing value.

startPosition
Type: System.Int32

The zero-based position in the formatted string where the replacement starts.

endPosition
Type: System.Int32

The zero-based position in the formatted string where the replacement ends.

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 the character was successfully replaced; otherwise, false.

The Replace(Char, Int32, Int32, Int32, MaskedTextResultHint) method searches for the first editable position in the formatted string between the specified starting and ending positions. If one is found, the value of the editable position is changed to the specified character, input. Any of the following conditions will result in an error condition that causes no replacement to be performed and a value of false to be returned:

  • The startPos or endPos parameters point before the start of the formatted string or beyond its end.

  • An editable character was not found in the specified interval.

  • The replacement character, input, is not a valid input character 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.6, 4.5, 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2015 Microsoft