mscorlib(4.0.0.0) API with additions
System.Xml.XmlConvert Class Reference

Encodes and decodes XML names, and provides methods for converting between common language runtime types and XML Schema definition language (XSD) types. When converting data types, the values returned are locale-independent. More...

Static Public Member Functions

static string EncodeName (string name)
 Converts the name to a valid XML name. More...
 
static string EncodeNmToken (string name)
 Verifies the name is valid according to the XML specification. More...
 
static string EncodeLocalName (string name)
 Converts the name to a valid XML local name. More...
 
static string DecodeName (string name)
 Decodes a name. This method does the reverse of the M:System.Xml.XmlConvert.EncodeName(System.String) and M:System.Xml.XmlConvert.EncodeLocalName(System.String) methods. More...
 
static string VerifyName (string name)
 Verifies that the name is a valid name according to the W3C Extended Markup Language recommendation. More...
 
static string VerifyNCName (string name)
 Verifies that the name is a valid NCName according to the W3C Extended Markup Language recommendation. An NCName is a name that cannot contain a colon. More...
 
static string VerifyTOKEN (string token)
 Verifies that the string is a valid token according to the W3C XML Schema Part2: Datatypes recommendation. More...
 
static string VerifyNMTOKEN (string name)
 Verifies that the string is a valid NMTOKEN according to the W3C XML Schema Part2: Datatypes recommendation More...
 
static string VerifyXmlChars (string content)
 Returns the passed-in string if all the characters and surrogate pair characters in the string argument are valid XML characters, otherwise an XmlException is thrown with information on the first invalid character encountered. More...
 
static string VerifyPublicId (string publicId)
 Returns the passed in string instance if all the characters in the string argument are valid public id characters. More...
 
static string VerifyWhitespace (string content)
 Returns the passed-in string instance if all the characters in the string argument are valid whitespace characters. More...
 
static unsafe bool IsStartNCNameChar (char ch)
 Checks if the passed-in character is a valid Start Name Character type. More...
 
static unsafe bool IsNCNameChar (char ch)
 Checks whether the passed-in character is a valid non-colon character type. More...
 
static unsafe bool IsXmlChar (char ch)
 Checks if the passed-in character is a valid XML character. More...
 
static bool IsXmlSurrogatePair (char lowChar, char highChar)
 Checks if the passed-in surrogate pair of characters is a valid XML character. More...
 
static bool IsPublicIdChar (char ch)
 Returns the passed-in character instance if the character in the argument is a valid public id character, otherwise null. More...
 
static unsafe bool IsWhitespaceChar (char ch)
 Checks if the passed-in character is a valid XML whitespace character. More...
 
static string ToString (bool value)
 Converts the T:System.Boolean to a T:System.String. More...
 
static string ToString (char value)
 Converts the T:System.Char to a T:System.String. More...
 
static string ToString (decimal value)
 Converts the T:System.Decimal to a T:System.String. More...
 
static string ToString (sbyte value)
 Converts the T:System.SByte to a T:System.String. More...
 
static string ToString (short value)
 Converts the T:System.Int16 to a T:System.String. More...
 
static string ToString (int value)
 Converts the T:System.Int32 to a T:System.String. More...
 
static string ToString (long value)
 Converts the T:System.Int64 to a T:System.String. More...
 
static string ToString (byte value)
 Converts the T:System.Byte to a T:System.String. More...
 
static string ToString (ushort value)
 Converts the T:System.UInt16 to a T:System.String. More...
 
static string ToString (uint value)
 Converts the T:System.UInt32 to a T:System.String. More...
 
static string ToString (ulong value)
 Converts the T:System.UInt64 to a T:System.String. More...
 
static string ToString (float value)
 Converts the T:System.Single to a T:System.String. More...
 
static string ToString (double value)
 Converts the T:System.Double to a T:System.String. More...
 
static string ToString (TimeSpan value)
 Converts the T:System.TimeSpan to a T:System.String. More...
 
static string ToString (DateTime value)
 Converts the T:System.DateTime to a T:System.String. More...
 
static string ToString (DateTime value, string format)
 Converts the T:System.DateTime to a T:System.String. More...
 
static string ToString (DateTime value, XmlDateTimeSerializationMode dateTimeOption)
 Converts the T:System.DateTime to a T:System.String using the T:System.Xml.XmlDateTimeSerializationMode specified. More...
 
static string ToString (DateTimeOffset value)
 Converts the supplied T:System.DateTimeOffset to a T:System.String. More...
 
static string ToString (DateTimeOffset value, string format)
 Converts the supplied T:System.DateTimeOffset to a T:System.String in the specified format. More...
 
static string ToString (Guid value)
 Converts the T:System.Guid to a T:System.String. More...
 
static bool ToBoolean (string s)
 Converts the T:System.String to a T:System.Boolean equivalent. More...
 
static char ToChar (string s)
 Converts the T:System.String to a T:System.Char equivalent. More...
 
static decimal ToDecimal (string s)
 Converts the T:System.String to a T:System.Decimal equivalent. More...
 
static sbyte ToSByte (string s)
 Converts the T:System.String to a T:System.SByte equivalent. More...
 
static short ToInt16 (string s)
 Converts the T:System.String to a T:System.Int16 equivalent. More...
 
static int ToInt32 (string s)
 Converts the T:System.String to a T:System.Int32 equivalent. More...
 
static long ToInt64 (string s)
 Converts the T:System.String to a T:System.Int64 equivalent. More...
 
static byte ToByte (string s)
 Converts the T:System.String to a T:System.Byte equivalent. More...
 
static ushort ToUInt16 (string s)
 Converts the T:System.String to a T:System.UInt16 equivalent. More...
 
static uint ToUInt32 (string s)
 Converts the T:System.String to a T:System.UInt32 equivalent. More...
 
static ulong ToUInt64 (string s)
 Converts the T:System.String to a T:System.UInt64 equivalent. More...
 
static float ToSingle (string s)
 Converts the T:System.String to a T:System.Single equivalent. More...
 
static double ToDouble (string s)
 Converts the T:System.String to a T:System.Double equivalent. More...
 
static TimeSpan ToTimeSpan (string s)
 Converts the T:System.String to a T:System.TimeSpan equivalent. More...
 
static DateTime ToDateTime (string s)
 Converts the T:System.String to a T:System.DateTime equivalent. More...
 
static DateTime ToDateTime (string s, string format)
 Converts the T:System.String to a T:System.DateTime equivalent. More...
 
static DateTime ToDateTime (string s, string[] formats)
 Converts the T:System.String to a T:System.DateTime equivalent. More...
 
static DateTime ToDateTime (string s, XmlDateTimeSerializationMode dateTimeOption)
 Converts the T:System.String to a T:System.DateTime using the T:System.Xml.XmlDateTimeSerializationMode specified More...
 
static DateTimeOffset ToDateTimeOffset (string s)
 Converts the supplied T:System.String to a T:System.DateTimeOffset equivalent. More...
 
static DateTimeOffset ToDateTimeOffset (string s, string format)
 Converts the supplied T:System.String to a T:System.DateTimeOffset equivalent. More...
 
static DateTimeOffset ToDateTimeOffset (string s, string[] formats)
 Converts the supplied T:System.String to a T:System.DateTimeOffset equivalent. More...
 
static Guid ToGuid (string s)
 Converts the T:System.String to a T:System.Guid equivalent. More...
 

Detailed Description

Encodes and decodes XML names, and provides methods for converting between common language runtime types and XML Schema definition language (XSD) types. When converting data types, the values returned are locale-independent.

Definition at line 11 of file XmlConvert.cs.

Member Function Documentation

◆ DecodeName()

static string System.Xml.XmlConvert.DecodeName ( string  name)
static

Decodes a name. This method does the reverse of the M:System.Xml.XmlConvert.EncodeName(System.String) and M:System.Xml.XmlConvert.EncodeLocalName(System.String) methods.

Parameters
nameThe name to be transformed.
Returns
The decoded name.

Definition at line 81 of file XmlConvert.cs.

◆ EncodeLocalName()

static string System.Xml.XmlConvert.EncodeLocalName ( string  name)
static

Converts the name to a valid XML local name.

Parameters
nameThe name to be encoded.
Returns
The encoded name.

Definition at line 72 of file XmlConvert.cs.

◆ EncodeName()

static string System.Xml.XmlConvert.EncodeName ( string  name)
static

Converts the name to a valid XML name.

Parameters
nameA name to be translated.
Returns
Returns the name with any invalid characters replaced by an escape string.

Definition at line 54 of file XmlConvert.cs.

◆ EncodeNmToken()

static string System.Xml.XmlConvert.EncodeNmToken ( string  name)
static

Verifies the name is valid according to the XML specification.

Parameters
nameThe name to be encoded.
Returns
The encoded name.

Definition at line 63 of file XmlConvert.cs.

◆ IsNCNameChar()

static unsafe bool System.Xml.XmlConvert.IsNCNameChar ( char  ch)
static

Checks whether the passed-in character is a valid non-colon character type.

Parameters
chThe character to verify as a non-colon character.
Returns
Returns true if the character is a valid non-colon character type; otherwise, false.

Definition at line 551 of file XmlConvert.cs.

◆ IsPublicIdChar()

static bool System.Xml.XmlConvert.IsPublicIdChar ( char  ch)
static

Returns the passed-in character instance if the character in the argument is a valid public id character, otherwise null.

Parameters
chT:System.Char object to validate.
Returns
Returns the passed-in character if the character is a valid public id character, otherwise null.

Definition at line 583 of file XmlConvert.cs.

◆ IsStartNCNameChar()

static unsafe bool System.Xml.XmlConvert.IsStartNCNameChar ( char  ch)
static

Checks if the passed-in character is a valid Start Name Character type.

Parameters
chThe character to validate.
Returns
true if the character is a valid Start Name Character type; otherwise, false.

Definition at line 543 of file XmlConvert.cs.

◆ IsWhitespaceChar()

static unsafe bool System.Xml.XmlConvert.IsWhitespaceChar ( char  ch)
static

Checks if the passed-in character is a valid XML whitespace character.

Parameters
chThe character to validate.
Returns
true if the passed in character is a valid XML whitespace character; otherwise false.

Definition at line 592 of file XmlConvert.cs.

◆ IsXmlChar()

static unsafe bool System.Xml.XmlConvert.IsXmlChar ( char  ch)
static

Checks if the passed-in character is a valid XML character.

Parameters
chThe character to validate.
Returns
true if the passed in character is a valid XML character; otherwise false.

Definition at line 560 of file XmlConvert.cs.

◆ IsXmlSurrogatePair()

static bool System.Xml.XmlConvert.IsXmlSurrogatePair ( char  lowChar,
char  highChar 
)
static

Checks if the passed-in surrogate pair of characters is a valid XML character.

Parameters
lowCharThe surrogate character to validate.
highCharThe surrogate character to validate.
Returns
true if the passed in surrogate pair of characters is a valid XML character; otherwise false.

Definition at line 570 of file XmlConvert.cs.

◆ ToBoolean()

static bool System.Xml.XmlConvert.ToBoolean ( string  s)
static

Converts the T:System.String to a T:System.Boolean equivalent.

Parameters
sThe string to convert.
Returns
A Boolean value, that is, true or false.
Exceptions
T:System.ArgumentNullExceptions is null.
T:System.FormatExceptions does not represent a Boolean value.

Definition at line 837 of file XmlConvert.cs.

◆ ToByte()

static byte System.Xml.XmlConvert.ToByte ( string  s)
static

Converts the T:System.String to a T:System.Byte equivalent.

Parameters
sThe string to convert.
Returns
A Byte equivalent of the string.
Exceptions
T:System.ArgumentNullExceptions is null.
T:System.FormatExceptions is not in the correct format.
T:System.OverflowExceptions represents a number less than F:System.Byte.MinValue or greater than F:System.Byte.MaxValue.

Definition at line 1045 of file XmlConvert.cs.

◆ ToChar()

static char System.Xml.XmlConvert.ToChar ( string  s)
static

Converts the T:System.String to a T:System.Char equivalent.

Parameters
sThe string containing a single character to convert.
Returns
A Char representing the single character.
Exceptions
T:System.ArgumentNullExceptionThe value of the s parameter is null.
T:System.FormatExceptionThe s parameter contains more than one character.

Definition at line 878 of file XmlConvert.cs.

◆ ToDateTime() [1/4]

static DateTime System.Xml.XmlConvert.ToDateTime ( string  s)
static

Converts the T:System.String to a T:System.DateTime equivalent.

Parameters
sThe string to convert.
Returns
A DateTime equivalent of the string.
Exceptions
T:System.ArgumentNullExceptions is null.
T:System.FormatExceptions is an empty string or is not in the correct format.

Definition at line 1386 of file XmlConvert.cs.

◆ ToDateTime() [2/4]

static DateTime System.Xml.XmlConvert.ToDateTime ( string  s,
string  format 
)
static

Converts the T:System.String to a T:System.DateTime equivalent.

Parameters
sThe string to convert.
formatThe format structure to apply to the converted DateTime. Valid formats include "yyyy-MM-ddTHH:mm:sszzzzzz" and its subsets. The string is validated against this format.
Returns
A DateTime equivalent of the string.
Exceptions
T:System.ArgumentNullExceptions is null.
T:System.FormatExceptions or format is String.Empty -or- s does not contain a date and time that corresponds to format .

Definition at line 1400 of file XmlConvert.cs.

◆ ToDateTime() [3/4]

static DateTime System.Xml.XmlConvert.ToDateTime ( string  s,
string []  formats 
)
static

Converts the T:System.String to a T:System.DateTime equivalent.

Parameters
sThe string to convert.
formatsAn array containing the format structures to apply to the converted DateTime. Valid formats include "yyyy-MM-ddTHH:mm:sszzzzzz" and its subsets.
Returns
A DateTime equivalent of the string.
Exceptions
T:System.ArgumentNullExceptions is null.
T:System.FormatExceptions or an element of formats is String.Empty -or- s does not contain a date and time that corresponds to any of the elements of formats .

Definition at line 1414 of file XmlConvert.cs.

◆ ToDateTime() [4/4]

static DateTime System.Xml.XmlConvert.ToDateTime ( string  s,
XmlDateTimeSerializationMode  dateTimeOption 
)
static

Converts the T:System.String to a T:System.DateTime using the T:System.Xml.XmlDateTimeSerializationMode specified

Parameters
sThe T:System.String value to convert.
dateTimeOptionOne of the T:System.Xml.XmlDateTimeSerializationMode values that specify whether the date should be converted to local time or preserved as Coordinated Universal Time (UTC), if it is a UTC date.
Returns
A T:System.DateTime equivalent of the T:System.String.
Exceptions
T:System.NullReferenceExceptions is null.
T:System.ArgumentNullExceptionThe dateTimeOption value is null.
T:System.FormatExceptions is an empty string or is not in a valid format.

Definition at line 1429 of file XmlConvert.cs.

◆ ToDateTimeOffset() [1/3]

static DateTimeOffset System.Xml.XmlConvert.ToDateTimeOffset ( string  s)
static

Converts the supplied T:System.String to a T:System.DateTimeOffset equivalent.

Parameters
sThe string to convert. Note   The string must conform to a subset of the W3C Recommendation for the XML dateTime type. For more information see http://www.w3.org/TR/xmlschema-2/#dateTime.
Returns
The T:System.DateTimeOffset equivalent of the supplied string.
Exceptions
T:System.ArgumentNullExceptions is null.
T:System.ArgumentOutOfRangeExceptionThe argument passed to this method is outside the range of allowable values. For information about allowable values, see T:System.DateTimeOffset.
T:System.FormatExceptionThe argument passed to this method does not conform to a subset of the W3C Recommendations for the XML dateTime type. For more information see http://www.w3.org/TR/xmlschema-2/#dateTime.

Definition at line 1461 of file XmlConvert.cs.

◆ ToDateTimeOffset() [2/3]

static DateTimeOffset System.Xml.XmlConvert.ToDateTimeOffset ( string  s,
string  format 
)
static

Converts the supplied T:System.String to a T:System.DateTimeOffset equivalent.

Parameters
sThe string to convert.
formatThe format from which s is converted. The format parameter can be any subset of the W3C Recommendation for the XML dateTime type. (For more information see http://www.w3.org/TR/xmlschema-2/#dateTime.) The string s is validated against this format.
Returns
The T:System.DateTimeOffset equivalent of the supplied string.
Exceptions
T:System.ArgumentNullExceptions is null.
T:System.FormatExceptions or format is an empty string or is not in the specified format.

Definition at line 1480 of file XmlConvert.cs.

◆ ToDateTimeOffset() [3/3]

static DateTimeOffset System.Xml.XmlConvert.ToDateTimeOffset ( string  s,
string []  formats 
)
static

Converts the supplied T:System.String to a T:System.DateTimeOffset equivalent.

Parameters
sThe string to convert.
formatsAn array of formats from which s can be converted. Each format in formats can be any subset of the W3C Recommendation for the XML dateTime type. (For more information see http://www.w3.org/TR/xmlschema-2/#dateTime.) The string s is validated against one of these formats.
Returns
The T:System.DateTimeOffset equivalent of the supplied string.

Definition at line 1494 of file XmlConvert.cs.

◆ ToDecimal()

static decimal System.Xml.XmlConvert.ToDecimal ( string  s)
static

Converts the T:System.String to a T:System.Decimal equivalent.

Parameters
sThe string to convert.
Returns
A Decimal equivalent of the string.
Exceptions
T:System.ArgumentNullExceptions is null.
T:System.FormatExceptions is not in the correct format.
T:System.OverflowExceptions represents a number less than F:System.Decimal.MinValue or greater than F:System.Decimal.MaxValue.

Definition at line 910 of file XmlConvert.cs.

◆ ToDouble()

static double System.Xml.XmlConvert.ToDouble ( string  s)
static

Converts the T:System.String to a T:System.Double equivalent.

Parameters
sThe string to convert.
Returns
A Double equivalent of the string.
Exceptions
T:System.ArgumentNullExceptions is null.
T:System.FormatExceptions is not in the correct format.
T:System.OverflowExceptions represents a number less than F:System.Double.MinValue or greater than F:System.Double.MaxValue.

Definition at line 1197 of file XmlConvert.cs.

◆ ToGuid()

static Guid System.Xml.XmlConvert.ToGuid ( string  s)
static

Converts the T:System.String to a T:System.Guid equivalent.

Parameters
sThe string to convert.
Returns
A Guid equivalent of the string.

Definition at line 1507 of file XmlConvert.cs.

◆ ToInt16()

static short System.Xml.XmlConvert.ToInt16 ( string  s)
static

Converts the T:System.String to a T:System.Int16 equivalent.

Parameters
sThe string to convert.
Returns
An Int16 equivalent of the string.
Exceptions
T:System.ArgumentNullExceptions is null.
T:System.FormatExceptions is not in the correct format.
T:System.OverflowExceptions represents a number less than F:System.Int16.MinValue or greater than F:System.Int16.MaxValue.

Definition at line 973 of file XmlConvert.cs.

◆ ToInt32()

static int System.Xml.XmlConvert.ToInt32 ( string  s)
static

Converts the T:System.String to a T:System.Int32 equivalent.

Parameters
sThe string to convert.
Returns
An Int32 equivalent of the string.
Exceptions
T:System.ArgumentNullExceptions is null.
T:System.FormatExceptions is not in the correct format.
T:System.OverflowExceptions represents a number less than F:System.Int32.MinValue or greater than F:System.Int32.MaxValue.

Definition at line 997 of file XmlConvert.cs.

◆ ToInt64()

static long System.Xml.XmlConvert.ToInt64 ( string  s)
static

Converts the T:System.String to a T:System.Int64 equivalent.

Parameters
sThe string to convert.
Returns
An Int64 equivalent of the string.
Exceptions
T:System.ArgumentNullExceptions is null.
T:System.FormatExceptions is not in the correct format.
T:System.OverflowExceptions represents a number less than F:System.Int64.MinValue or greater than F:System.Int64.MaxValue.

Definition at line 1021 of file XmlConvert.cs.

◆ ToSByte()

static sbyte System.Xml.XmlConvert.ToSByte ( string  s)
static

Converts the T:System.String to a T:System.SByte equivalent.

Parameters
sThe string to convert.
Returns
An SByte equivalent of the string.
Exceptions
T:System.ArgumentNullExceptions is null.
T:System.FormatExceptions is not in the correct format.
T:System.OverflowExceptions represents a number less than F:System.SByte.MinValue or greater than F:System.SByte.MaxValue.

Definition at line 949 of file XmlConvert.cs.

◆ ToSingle()

static float System.Xml.XmlConvert.ToSingle ( string  s)
static

Converts the T:System.String to a T:System.Single equivalent.

Parameters
sThe string to convert.
Returns
A Single equivalent of the string.
Exceptions
T:System.ArgumentNullExceptions is null.
T:System.FormatExceptions is not in the correct format.
T:System.OverflowExceptions represents a number less than F:System.Single.MinValue or greater than F:System.Single.MaxValue.

Definition at line 1144 of file XmlConvert.cs.

◆ ToString() [1/20]

static string System.Xml.XmlConvert.ToString ( bool  value)
static

Converts the T:System.Boolean to a T:System.String.

Parameters
valueThe value to convert.
Returns
A string representation of the Boolean, that is, "true" or "false".

Definition at line 601 of file XmlConvert.cs.

◆ ToString() [2/20]

static string System.Xml.XmlConvert.ToString ( char  value)
static

Converts the T:System.Char to a T:System.String.

Parameters
valueThe value to convert.
Returns
A string representation of the Char.

Definition at line 614 of file XmlConvert.cs.

◆ ToString() [3/20]

static string System.Xml.XmlConvert.ToString ( decimal  value)
static

Converts the T:System.Decimal to a T:System.String.

Parameters
valueThe value to convert.
Returns
A string representation of the Decimal.

Definition at line 623 of file XmlConvert.cs.

◆ ToString() [4/20]

static string System.Xml.XmlConvert.ToString ( sbyte  value)
static

Converts the T:System.SByte to a T:System.String.

Parameters
valueThe value to convert.
Returns
A string representation of the SByte.

Definition at line 633 of file XmlConvert.cs.

◆ ToString() [5/20]

static string System.Xml.XmlConvert.ToString ( short  value)
static

Converts the T:System.Int16 to a T:System.String.

Parameters
valueThe value to convert.
Returns
A string representation of the Int16.

Definition at line 642 of file XmlConvert.cs.

◆ ToString() [6/20]

static string System.Xml.XmlConvert.ToString ( int  value)
static

Converts the T:System.Int32 to a T:System.String.

Parameters
valueThe value to convert.
Returns
A string representation of the Int32.

Definition at line 651 of file XmlConvert.cs.

◆ ToString() [7/20]

static string System.Xml.XmlConvert.ToString ( long  value)
static

Converts the T:System.Int64 to a T:System.String.

Parameters
valueThe value to convert.
Returns
A string representation of the Int64.

Definition at line 660 of file XmlConvert.cs.

◆ ToString() [8/20]

static string System.Xml.XmlConvert.ToString ( byte  value)
static

Converts the T:System.Byte to a T:System.String.

Parameters
valueThe value to convert.
Returns
A string representation of the Byte.

Definition at line 669 of file XmlConvert.cs.

◆ ToString() [9/20]

static string System.Xml.XmlConvert.ToString ( ushort  value)
static

Converts the T:System.UInt16 to a T:System.String.

Parameters
valueThe value to convert.
Returns
A string representation of the UInt16.

Definition at line 679 of file XmlConvert.cs.

◆ ToString() [10/20]

static string System.Xml.XmlConvert.ToString ( uint  value)
static

Converts the T:System.UInt32 to a T:System.String.

Parameters
valueThe value to convert.
Returns
A string representation of the UInt32.

Definition at line 689 of file XmlConvert.cs.

◆ ToString() [11/20]

static string System.Xml.XmlConvert.ToString ( ulong  value)
static

Converts the T:System.UInt64 to a T:System.String.

Parameters
valueThe value to convert.
Returns
A string representation of the UInt64.

Definition at line 699 of file XmlConvert.cs.

◆ ToString() [12/20]

static string System.Xml.XmlConvert.ToString ( float  value)
static

Converts the T:System.Single to a T:System.String.

Parameters
valueThe value to convert.
Returns
A string representation of the Single.

Definition at line 708 of file XmlConvert.cs.

◆ ToString() [13/20]

static string System.Xml.XmlConvert.ToString ( double  value)
static

Converts the T:System.Double to a T:System.String.

Parameters
valueThe value to convert.
Returns
A string representation of the Double.

Definition at line 729 of file XmlConvert.cs.

◆ ToString() [14/20]

static string System.Xml.XmlConvert.ToString ( TimeSpan  value)
static

Converts the T:System.TimeSpan to a T:System.String.

Parameters
valueThe value to convert.
Returns
A string representation of the TimeSpan.

Definition at line 750 of file XmlConvert.cs.

◆ ToString() [15/20]

static string System.Xml.XmlConvert.ToString ( DateTime  value)
static

Converts the T:System.DateTime to a T:System.String.

Parameters
valueThe value to convert.
Returns
A string representation of the DateTime in the format yyyy-MM-ddTHH:mm:ss where 'T' is a constant literal.

Definition at line 759 of file XmlConvert.cs.

◆ ToString() [16/20]

static string System.Xml.XmlConvert.ToString ( DateTime  value,
string  format 
)
static

Converts the T:System.DateTime to a T:System.String.

Parameters
valueThe value to convert.
formatThe format structure that defines how to display the converted string. Valid formats include "yyyy-MM-ddTHH:mm:sszzzzzz" and its subsets.
Returns
A string representation of the DateTime in the specified format.

Definition at line 768 of file XmlConvert.cs.

◆ ToString() [17/20]

static string System.Xml.XmlConvert.ToString ( DateTime  value,
XmlDateTimeSerializationMode  dateTimeOption 
)
static

Converts the T:System.DateTime to a T:System.String using the T:System.Xml.XmlDateTimeSerializationMode specified.

Parameters
valueThe T:System.DateTime value to convert.
dateTimeOptionOne of the T:System.Xml.XmlDateTimeSerializationMode values that specify how to treat the T:System.DateTime value.
Returns
A T:System.String equivalent of the T:System.DateTime.
Exceptions
T:System.ArgumentExceptionThe dateTimeOption value is not valid.
T:System.ArgumentNullExceptionThe value or dateTimeOption value is null.

Definition at line 780 of file XmlConvert.cs.

◆ ToString() [18/20]

static string System.Xml.XmlConvert.ToString ( DateTimeOffset  value)
static

Converts the supplied T:System.DateTimeOffset to a T:System.String.

Parameters
valueThe T:System.DateTimeOffset to be converted.
Returns
A T:System.String representation of the supplied T:System.DateTimeOffset.

Definition at line 805 of file XmlConvert.cs.

◆ ToString() [19/20]

static string System.Xml.XmlConvert.ToString ( DateTimeOffset  value,
string  format 
)
static

Converts the supplied T:System.DateTimeOffset to a T:System.String in the specified format.

Parameters
valueThe T:System.DateTimeOffset to be converted.
formatThe format to which s is converted. The format parameter can be any subset of the W3C Recommendation for the XML dateTime type. (For more information see http://www.w3.org/TR/xmlschema-2/#dateTime.)
Returns
A T:System.String representation in the specified format of the supplied T:System.DateTimeOffset.

Definition at line 815 of file XmlConvert.cs.

◆ ToString() [20/20]

static string System.Xml.XmlConvert.ToString ( Guid  value)
static

Converts the T:System.Guid to a T:System.String.

Parameters
valueThe value to convert.
Returns
A string representation of the Guid.

Definition at line 824 of file XmlConvert.cs.

◆ ToTimeSpan()

static TimeSpan System.Xml.XmlConvert.ToTimeSpan ( string  s)
static

Converts the T:System.String to a T:System.TimeSpan equivalent.

Parameters
sThe string to convert. The string format must conform to the W3C XML Schema Part 2: Datatypes recommendation for duration.
Returns
A TimeSpan equivalent of the string.
Exceptions
T:System.FormatExceptions is not in correct format to represent a TimeSpan value.

Definition at line 1318 of file XmlConvert.cs.

◆ ToUInt16()

static ushort System.Xml.XmlConvert.ToUInt16 ( string  s)
static

Converts the T:System.String to a T:System.UInt16 equivalent.

Parameters
sThe string to convert.
Returns
A UInt16 equivalent of the string.
Exceptions
T:System.ArgumentNullExceptions is null.
T:System.FormatExceptions is not in the correct format.
T:System.OverflowExceptions represents a number less than F:System.UInt16.MinValue or greater than F:System.UInt16.MaxValue.

Definition at line 1070 of file XmlConvert.cs.

◆ ToUInt32()

static uint System.Xml.XmlConvert.ToUInt32 ( string  s)
static

Converts the T:System.String to a T:System.UInt32 equivalent.

Parameters
sThe string to convert.
Returns
A UInt32 equivalent of the string.
Exceptions
T:System.ArgumentNullExceptions is null.
T:System.FormatExceptions is not in the correct format.
T:System.OverflowExceptions represents a number less than F:System.UInt32.MinValue or greater than F:System.UInt32.MaxValue.

Definition at line 1095 of file XmlConvert.cs.

◆ ToUInt64()

static ulong System.Xml.XmlConvert.ToUInt64 ( string  s)
static

Converts the T:System.String to a T:System.UInt64 equivalent.

Parameters
sThe string to convert.
Returns
A UInt64 equivalent of the string.
Exceptions
T:System.ArgumentNullExceptions is null.
T:System.FormatExceptions is not in the correct format.
T:System.OverflowExceptions represents a number less than F:System.UInt64.MinValue or greater than F:System.UInt64.MaxValue.

Definition at line 1120 of file XmlConvert.cs.

◆ VerifyName()

static string System.Xml.XmlConvert.VerifyName ( string  name)
static

Verifies that the name is a valid name according to the W3C Extended Markup Language recommendation.

Parameters
nameThe name to verify.
Returns
The name, if it is a valid XML name.
Exceptions
T:System.Xml.XmlExceptionname is not a valid XML name.
T:System.ArgumentNullExceptionname is null or String.Empty.

Definition at line 301 of file XmlConvert.cs.

◆ VerifyNCName()

static string System.Xml.XmlConvert.VerifyNCName ( string  name)
static

Verifies that the name is a valid NCName according to the W3C Extended Markup Language recommendation. An NCName is a name that cannot contain a colon.

Parameters
nameThe name to verify.
Returns
The name, if it is a valid NCName.
Exceptions
T:System.ArgumentNullExceptionname is null or String.Empty.
T:System.Xml.XmlExceptionname is not a valid non-colon name.

Definition at line 361 of file XmlConvert.cs.

◆ VerifyNMTOKEN()

static string System.Xml.XmlConvert.VerifyNMTOKEN ( string  name)
static

Verifies that the string is a valid NMTOKEN according to the W3C XML Schema Part2: Datatypes recommendation

Parameters
nameThe string you wish to verify.
Returns
The name token, if it is a valid NMTOKEN.
Exceptions
T:System.Xml.XmlExceptionThe string is not a valid name token.
T:System.ArgumentNullExceptionname is null.

Definition at line 431 of file XmlConvert.cs.

◆ VerifyPublicId()

static string System.Xml.XmlConvert.VerifyPublicId ( string  publicId)
static

Returns the passed in string instance if all the characters in the string argument are valid public id characters.

Parameters
publicIdT:System.String that contains the id to validate.
Returns
Returns the passed-in string if all the characters in the argument are valid public id characters.

Definition at line 506 of file XmlConvert.cs.

◆ VerifyTOKEN()

static string System.Xml.XmlConvert.VerifyTOKEN ( string  token)
static

Verifies that the string is a valid token according to the W3C XML Schema Part2: Datatypes recommendation.

Parameters
tokenThe string value you wish to verify.
Returns
The token, if it is a valid token.
Exceptions
T:System.Xml.XmlExceptionThe string value is not a valid token.

Definition at line 398 of file XmlConvert.cs.

◆ VerifyWhitespace()

static string System.Xml.XmlConvert.VerifyWhitespace ( string  content)
static

Returns the passed-in string instance if all the characters in the string argument are valid whitespace characters.

Parameters
contentT:System.String to verify.
Returns
Returns the passed-in string instance if all the characters in the string argument are valid whitespace characters, otherwise null.

Definition at line 525 of file XmlConvert.cs.

◆ VerifyXmlChars()

static string System.Xml.XmlConvert.VerifyXmlChars ( string  content)
static

Returns the passed-in string if all the characters and surrogate pair characters in the string argument are valid XML characters, otherwise an XmlException is thrown with information on the first invalid character encountered.

Parameters
contentT:System.String that contains characters to verify.
Returns
Returns the passed-in string if all the characters and surrogate-pair characters in the string argument are valid XML characters, otherwise an XmlException is thrown with information on the first invalid character encountered.

Definition at line 491 of file XmlConvert.cs.


The documentation for this class was generated from the following file: