.NET Documentation

XmlConvert Class

Namespace: System.Xml
Provides a collection of methods for converting between .NET data types and XML data types, and for encoding and decoding strings.

Methods

Boolean ToBoolean(string s)

public static bool ToBoolean(string s)
Converts the specified string representation of a Boolean value to its Boolean equivalent.
Parameters:
  • s: The string to convert.
Returns: true if s represents true; otherwise, false.

DateTime ToDateTime(string s)

public static DateTime ToDateTime(string s)
Converts the specified string representation of a date and time to its DateTime equivalent.
Parameters:
  • s: The string to convert.
Returns: A DateTime structure that represents the value of the string.

string EncodeLocalName(string str)

public static string EncodeLocalName(string str)
Encodes a string so that it can be used as an XML local name.
Parameters:
  • str: The string to encode.
Returns: The encoded string.

string EncodeNmToken(string str)

public static string EncodeNmToken(string str)
Encodes a string so that it can be used as an XML NameToken.
Parameters:
  • str: The string to encode.
Returns: The encoded string.

string EncodeWhitespace(string str)

public static string EncodeWhitespace(string str)
Encodes whitespace characters in a string for use in an XML attribute value.
Parameters:
  • str: The string to encode.
Returns: The encoded string.

decimal ToDecimal(string s)

public static decimal ToDecimal(string s)
Converts the specified string representation of a decimal number to its decimal equivalent.
Parameters:
  • s: The string to convert.
Returns: A decimal number that represents the value of the string.

int ToInt32(string s)

public static int ToInt32(string s)
Converts the specified string representation of a 32-bit signed integer to its 32-bit signed integer equivalent.
Parameters:
  • s: The string to convert.
Returns: A 32-bit signed integer that represents the value of the string.

long ToInt64(string s)

public static long ToInt64(string s)
Converts the specified string representation of a 64-bit signed integer to its 64-bit signed integer equivalent.
Parameters:
  • s: The string to convert.
Returns: A 64-bit signed integer that represents the value of the string.

string ToString(bool value)

public static string ToString(bool value)
Converts the specified Boolean value to its string representation.
Parameters:
  • value: The Boolean value to convert.
Returns: The string representation of the Boolean value.

string ToString(DateTime value)

public static string ToString(DateTime value)
Converts the specified DateTime value to its string representation.
Parameters:
  • value: The DateTime value to convert.
Returns: The string representation of the DateTime value.

string ToString(decimal value)

public static string ToString(decimal value)
Converts the specified decimal value to its string representation.
Parameters:
  • value: The decimal value to convert.
Returns: The string representation of the decimal value.

string ToString(int value)

public static string ToString(int value)
Converts the specified 32-bit signed integer value to its string representation.
Parameters:
  • value: The 32-bit signed integer value to convert.
Returns: The string representation of the 32-bit signed integer value.

string ToString(long value)

public static string ToString(long value)
Converts the specified 64-bit signed integer value to its string representation.
Parameters:
  • value: The 64-bit signed integer value to convert.
Returns: The string representation of the 64-bit signed integer value.