System.Security.SecurityElement.Escape Method

Replaces invalid XML characters in a string with their valid XML equivalent.

Syntax

public static string Escape (string str)

Parameters

str
The string within which to escape invalid characters.

Returns

The input string with invalid characters replaced.

Remarks

Use this method to replace invalid characters in a string before using the string in a System.Security.SecurityElement. If invalid characters are used in a System.Security.SecurityElement without being escaped, an ArgumentException is thrown.

The following table shows the invalid XML characters and their escaped equivalents.

"<"

"&lt;"

">"

"&gt;"

"\""

"&quot;"

"\'"

"&apos;"

"&"

"&amp;"

Requirements

Namespace: System.Security
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0, 4.0.0.0