Modifica

Condividi tramite


XAttribute.Explicit Operator

Definition

Overloads

Explicit(XAttribute to Nullable<Int64>)

Cast the value of this XAttribute to a Nullable<T> of Int64.

Explicit(XAttribute to Nullable<Single>)

Cast the value of this XAttribute to a Nullable<T> of Single.

Explicit(XAttribute to Nullable<TimeSpan>)

Cast the value of this XAttribute to a Nullable<T> of TimeSpan.

Explicit(XAttribute to Nullable<UInt32>)

Cast the value of this XAttribute to a Nullable<T> of UInt32.

Explicit(XAttribute to Nullable<UInt64>)

Cast the value of this XAttribute to a Nullable<T> of UInt64.

Explicit(XAttribute to TimeSpan)

Cast the value of this XAttribute to a TimeSpan.

Explicit(XAttribute to String)

Cast the value of this XAttribute to a String.

Explicit(XAttribute to Nullable<Int32>)

Cast the value of this XAttribute to a Nullable<T> of Int32.

Explicit(XAttribute to UInt32)

Cast the value of this XAttribute to a UInt32.

Explicit(XAttribute to UInt64)

Cast the value of this XAttribute to a UInt64.

Explicit(XAttribute to Single)

Cast the value of this XAttribute to a Single.

Explicit(XAttribute to Nullable<Guid>)

Cast the value of this XAttribute to a Nullable<T> of Guid.

Explicit(XAttribute to Nullable<Decimal>)

Cast the value of this XAttribute to a Nullable<T> of Decimal.

Explicit(XAttribute to Decimal)

Cast the value of this XAttribute to a Decimal.

Explicit(XAttribute to Nullable<DateTimeOffset>)

Cast the value of this XAttribute to a Nullable<T> of DateTimeOffset.

Explicit(XAttribute to Nullable<DateTime>)

Cast the value of this XAttribute to a Nullable<T> of DateTime.

Explicit(XAttribute to Nullable<Boolean>)

Cast the value of this XAttribute to a Nullable<T> of Boolean.

Explicit(XAttribute to Int64)

Cast the value of this XAttribute to an Int64.

Explicit(XAttribute to Int32)

Cast the value of this XAttribute to an Int32.

Explicit(XAttribute to Guid)

Cast the value of this XAttribute to a Guid.

Explicit(XAttribute to Double)

Cast the value of this XAttribute to a Double.

Explicit(XAttribute to Nullable<Double>)

Cast the value of this XAttribute to a Nullable<T> of Double.

Explicit(XAttribute to DateTimeOffset)

Cast the value of this XAttribute to a DateTimeOffset.

Explicit(XAttribute to DateTime)

Cast the value of this XAttribute to a DateTime.

Explicit(XAttribute to Boolean)

Cast the value of this XAttribute to a Boolean.

Explicit(XAttribute to Nullable<Int64>)

Source:
XAttribute.cs
Source:
XAttribute.cs
Source:
XAttribute.cs

Important

This API is not CLS-compliant.

Cast the value of this XAttribute to a Nullable<T> of Int64.

public:
 static explicit operator Nullable<long>(System::Xml::Linq::XAttribute ^ attribute);
[System.CLSCompliant(false)]
public static explicit operator long? (System.Xml.Linq.XAttribute attribute);
[System.CLSCompliant(false)]
public static explicit operator long? (System.Xml.Linq.XAttribute? attribute);
[<System.CLSCompliant(false)>]
static member op_Explicit : System.Xml.Linq.XAttribute -> Nullable<int64>
Public Shared Narrowing Operator CType (attribute As XAttribute) As Nullable(Of Long)

Parameters

attribute
XAttribute

The XAttribute to cast to a Nullable<T> of Int64.

Returns

A Nullable<T> of Int64 that contains the content of this XAttribute.

Attributes

Exceptions

The attribute does not contain a valid Int64 value.

Examples

The following example creates an attribute with long integer content. It then retrieves the value by casting to Nullable<T> of Int64.

XElement root = new XElement("Root",   
    new XAttribute("Att", 9223372036854775807)  
);  
long? value = (long?)root.Attribute("Att");  
Console.WriteLine("Nullable long: value={0}", value == null ? "null" : value.ToString());  
Dim root As XElement = <Root Att="9223372036854775807"/>  
Dim value As Nullable(Of Long) = CType(root.Attribute("Att"), Nullable(Of Long))  
Console.WriteLine("Nullable long: value={0}", IIf(value.HasValue, value.ToString(), "null"))  

This example produces the following output:

Nullable long: value=9223372036854775807  

See also

Applies to

Explicit(XAttribute to Nullable<Single>)

Source:
XAttribute.cs
Source:
XAttribute.cs
Source:
XAttribute.cs

Important

This API is not CLS-compliant.

Cast the value of this XAttribute to a Nullable<T> of Single.

public:
 static explicit operator Nullable<float>(System::Xml::Linq::XAttribute ^ attribute);
[System.CLSCompliant(false)]
public static explicit operator float? (System.Xml.Linq.XAttribute attribute);
[System.CLSCompliant(false)]
public static explicit operator float? (System.Xml.Linq.XAttribute? attribute);
[<System.CLSCompliant(false)>]
static member op_Explicit : System.Xml.Linq.XAttribute -> Nullable<single>
Public Shared Narrowing Operator CType (attribute As XAttribute) As Nullable(Of Single)

Parameters

attribute
XAttribute

The XAttribute to cast to Nullable<T> of Single.

Returns

A Nullable<T> of Single that contains the content of this XAttribute.

Attributes

Exceptions

The attribute does not contain a valid Single value.

Examples

The following example creates an attribute with single precision floating point content. It then retrieves the value by casting to Nullable<T> of Single.

XElement root = new XElement("Root",   
    new XAttribute("Att", 3.402823e38)  
);  
float? value = (float?)root.Attribute("Att");  
Console.WriteLine("Nullable Single: value={0}", value == null ? "null" : value.ToString());  
Dim root As XElement = <Root Att="3.402823E+38"/>  
Dim value As Nullable(Of Single) = CType(root.Attribute("Att"), Nullable(Of Single))  
Console.WriteLine("Nullable Single: value={0}", IIf(value.HasValue, value.ToString(), "null"))  

This example produces the following output:

Nullable Single: value=3.402823E+38  

See also

Applies to

Explicit(XAttribute to Nullable<TimeSpan>)

Source:
XAttribute.cs
Source:
XAttribute.cs
Source:
XAttribute.cs

Important

This API is not CLS-compliant.

Cast the value of this XAttribute to a Nullable<T> of TimeSpan.

public:
 static explicit operator Nullable<TimeSpan>(System::Xml::Linq::XAttribute ^ attribute);
[System.CLSCompliant(false)]
public static explicit operator TimeSpan? (System.Xml.Linq.XAttribute attribute);
[System.CLSCompliant(false)]
public static explicit operator TimeSpan? (System.Xml.Linq.XAttribute? attribute);
[<System.CLSCompliant(false)>]
static member op_Explicit : System.Xml.Linq.XAttribute -> Nullable<TimeSpan>
Public Shared Narrowing Operator CType (attribute As XAttribute) As Nullable(Of TimeSpan)

Parameters

attribute
XAttribute

The XAttribute to cast to a Nullable<T> of TimeSpan.

Returns

A Nullable<T> of TimeSpan that contains the content of this XAttribute.

Attributes

Exceptions

The attribute does not contain a valid TimeSpan value.

Examples

The following example creates an attribute with time span content. It then retrieves the value by casting to Nullable<T> of TimeSpan.

XElement root = new XElement("Root",  
    new XAttribute("Att", new TimeSpan(1, 5, 30))  
);  
TimeSpan? value = (TimeSpan?)root.Attribute("Att");  
Console.WriteLine("Nullable TimeSpan: value={0}", value == null ? "null" : value.ToString());  
Dim root As XElement = <Root Att=<%= New TimeSpan(1, 5, 30) %>/>  
Dim value As Nullable(Of TimeSpan) = CType(root.Attribute("Att"), Nullable(Of TimeSpan))  
Console.WriteLine("Nullable TimeSpan: value={0}", IIf(value.HasValue, value.ToString(), "null"))  

This example produces the following output:

Nullable TimeSpan: value=01:05:30  

Remarks

The value space of an attribute or element that contains time span content is closely related to duration content as described in ISO 8601. When creating an attribute or element that contains time span content, the attribute or element values are formatted per the W3C specification. Please see the W3C specification for more details.

Behavior is lax when casting to a Nullable<T> of TimeSpan from an attribute or element. Even if the attribute or element value is not formatted exactly per the W3C specification, the value is appropriately converted to a Nullable<T> of TimeSpan.

See also

Applies to

Explicit(XAttribute to Nullable<UInt32>)

Source:
XAttribute.cs
Source:
XAttribute.cs
Source:
XAttribute.cs

Important

This API is not CLS-compliant.

Cast the value of this XAttribute to a Nullable<T> of UInt32.

public:
 static explicit operator Nullable<System::UInt32>(System::Xml::Linq::XAttribute ^ attribute);
[System.CLSCompliant(false)]
public static explicit operator uint? (System.Xml.Linq.XAttribute attribute);
[System.CLSCompliant(false)]
public static explicit operator uint? (System.Xml.Linq.XAttribute? attribute);
[<System.CLSCompliant(false)>]
static member op_Explicit : System.Xml.Linq.XAttribute -> Nullable<uint32>
Public Shared Narrowing Operator CType (attribute As XAttribute) As Nullable(Of UInteger)

Parameters

attribute
XAttribute

The XAttribute to cast to a Nullable<T> of UInt32.

Returns

A Nullable<T> of UInt32 that contains the content of this XAttribute.

Attributes

Exceptions

The attribute does not contain a valid UInt32 value.

Examples

The following example creates an attribute with unsigned integer content. It then retrieves the value by casting to Nullable<T> of UInt32.

XElement root = new XElement("Root",   
    new XAttribute("Att", 4294967295)  
);  
uint? value = (uint?)root.Attribute("Att");  
Console.WriteLine("Nullable uint: value={0}", value == null ? "null" : value.ToString());  
Dim root As XElement = <Root Att="4294967295"/>  
Dim value As Nullable(Of UInteger) = CType(root.Attribute("Att"), Nullable(Of UInteger))  
Console.WriteLine("Nullable uint: value={0}", IIf(value.HasValue, value.ToString(), "null"))  

This example produces the following output:

Nullable uint: value=4294967295  

See also

Applies to

Explicit(XAttribute to Nullable<UInt64>)

Source:
XAttribute.cs
Source:
XAttribute.cs
Source:
XAttribute.cs

Important

This API is not CLS-compliant.

Cast the value of this XAttribute to a Nullable<T> of UInt64.

public:
 static explicit operator Nullable<System::UInt64>(System::Xml::Linq::XAttribute ^ attribute);
[System.CLSCompliant(false)]
public static explicit operator ulong? (System.Xml.Linq.XAttribute attribute);
[System.CLSCompliant(false)]
public static explicit operator ulong? (System.Xml.Linq.XAttribute? attribute);
[<System.CLSCompliant(false)>]
static member op_Explicit : System.Xml.Linq.XAttribute -> Nullable<uint64>
Public Shared Narrowing Operator CType (attribute As XAttribute) As Nullable(Of ULong)

Parameters

attribute
XAttribute

The XAttribute to cast to a Nullable<T> of UInt64.

Returns

A Nullable<T> of UInt64 that contains the content of this XAttribute.

Attributes

Exceptions

The attribute does not contain a valid UInt64 value.

Examples

The following example creates an attribute with unsigned long integer content. It then retrieves the value by casting to Nullable<T> of UInt64.

XElement root = new XElement("Root",   
    new XAttribute("Att", 9223372036854775807)  
);  
ulong? value = (ulong?)root.Attribute("Att");  
Console.WriteLine("Nullable ulong: value={0}", value == null ? "null" : value.ToString());  
Dim root As XElement = <Root Att="9223372036854775807"/>  
Dim value As Nullable(Of ULong) = CType(root.Attribute("Att"), Nullable(Of ULong))  
Console.WriteLine("Nullable ulong: value={0}", IIf(value.HasValue, value.ToString(), "null"))  

This example produces the following output:

Nullable ulong: value=9223372036854775807  

See also

Applies to

Explicit(XAttribute to TimeSpan)

Source:
XAttribute.cs
Source:
XAttribute.cs
Source:
XAttribute.cs

Important

This API is not CLS-compliant.

Cast the value of this XAttribute to a TimeSpan.

public:
 static explicit operator TimeSpan(System::Xml::Linq::XAttribute ^ attribute);
[System.CLSCompliant(false)]
public static explicit operator TimeSpan (System.Xml.Linq.XAttribute attribute);
[<System.CLSCompliant(false)>]
static member op_Explicit : System.Xml.Linq.XAttribute -> TimeSpan
Public Shared Narrowing Operator CType (attribute As XAttribute) As TimeSpan

Parameters

attribute
XAttribute

The XAttribute to cast to TimeSpan.

Returns

A TimeSpan that contains the content of this XAttribute.

Attributes

Exceptions

The attribute does not contain a valid TimeSpan value.

The attribute parameter is null.

Examples

The following example creates an attribute with time span content. It then retrieves the value by casting to TimeSpan.

XElement root = new XElement("Root",  
    new XAttribute("Att", new TimeSpan(1, 5, 30))  
);  
TimeSpan value = (TimeSpan)root.Attribute("Att");  
Console.WriteLine("value={0}", value);  
Dim root As XElement = <Root Att=<%= New TimeSpan(1, 5, 30) %>/>  
Dim value As TimeSpan = CType(root.Attribute("Att"), TimeSpan)  
Console.WriteLine("value={0}", value)  

This example produces the following output:

value=01:05:30  

Remarks

The value space of an attribute or element that contains time span content is closely related to duration content as described in ISO 8601. When creating an attribute or element that contains time span content, the attribute or element values are formatted per the W3C specification. Please see the W3C specification for more details.

Behavior is lax when casting to a TimeSpan from an attribute or element. Even if the attribute or element value is not formatted exactly per the W3C specification, the value is appropriately converted to a TimeSpan.

See also

Applies to

Explicit(XAttribute to String)

Source:
XAttribute.cs
Source:
XAttribute.cs
Source:
XAttribute.cs

Important

This API is not CLS-compliant.

Cast the value of this XAttribute to a String.

public:
 static explicit operator System::String ^(System::Xml::Linq::XAttribute ^ attribute);
[System.CLSCompliant(false)]
public static explicit operator string (System.Xml.Linq.XAttribute attribute);
[System.CLSCompliant(false)]
public static explicit operator string? (System.Xml.Linq.XAttribute? attribute);
[<System.CLSCompliant(false)>]
static member op_Explicit : System.Xml.Linq.XAttribute -> string
Public Shared Narrowing Operator CType (attribute As XAttribute) As String

Parameters

attribute
XAttribute

The XAttribute to cast to String.

Returns

A String that contains the content of this XAttribute.

Attributes

Examples

The following example creates an attribute with string content. It then retrieves the value by casting to String.

XElement root = new XElement("Root",  
    new XAttribute("Att", "attribute content")  
);  
XAttribute att = root.Attribute("Att");  
string str = (string)att;  
Console.WriteLine("(string)att={0}", str);  
Dim root As XElement = <Root Att="attribute content"/>  
Dim att As XAttribute = root.Attribute("Att")  
Dim str As String = CStr(att)  
Console.WriteLine("(string)att={0}", str)  

This example produces the following output:

(string)att=attribute content  

See also

Applies to

Explicit(XAttribute to Nullable<Int32>)

Source:
XAttribute.cs
Source:
XAttribute.cs
Source:
XAttribute.cs

Important

This API is not CLS-compliant.

Cast the value of this XAttribute to a Nullable<T> of Int32.

public:
 static explicit operator Nullable<int>(System::Xml::Linq::XAttribute ^ attribute);
[System.CLSCompliant(false)]
public static explicit operator int? (System.Xml.Linq.XAttribute attribute);
[System.CLSCompliant(false)]
public static explicit operator int? (System.Xml.Linq.XAttribute? attribute);
[<System.CLSCompliant(false)>]
static member op_Explicit : System.Xml.Linq.XAttribute -> Nullable<int>
Public Shared Narrowing Operator CType (attribute As XAttribute) As Nullable(Of Integer)

Parameters

attribute
XAttribute

The XAttribute to cast to a Nullable<T> of Int32.

Returns

A Nullable<T> of Int32 that contains the content of this XAttribute.

Attributes

Examples

The following example creates an attribute with integer content. It then retrieves the value by casting to Nullable<T> of Int32.

XElement root = new XElement("Root",   
    new XAttribute("Att", 2147483647)  
);  
int? value = (int?)root.Attribute("Att");  
Console.WriteLine("Nullable int: value={0}", value == null ? "null" : value.ToString());  
Dim root As XElement = <Root Att="2147483647"/>  
Dim value As Nullable(Of Integer) = CType(root.Attribute("Att"), Nullable(Of Integer))  
Console.WriteLine("Nullable int: value={0}", IIf(value.HasValue, value.ToString(), "null"))  

This example produces the following output:

Nullable int: value=2147483647  

See also

Applies to

Explicit(XAttribute to UInt32)

Source:
XAttribute.cs
Source:
XAttribute.cs
Source:
XAttribute.cs

Important

This API is not CLS-compliant.

Cast the value of this XAttribute to a UInt32.

public:
 static explicit operator System::UInt32(System::Xml::Linq::XAttribute ^ attribute);
[System.CLSCompliant(false)]
public static explicit operator uint (System.Xml.Linq.XAttribute attribute);
[<System.CLSCompliant(false)>]
static member op_Explicit : System.Xml.Linq.XAttribute -> uint32
Public Shared Narrowing Operator CType (attribute As XAttribute) As UInteger

Parameters

attribute
XAttribute

The XAttribute to cast to UInt32.

Returns

A UInt32 that contains the content of this XAttribute.

Attributes

Exceptions

The attribute does not contain a valid UInt32 value.

The attribute parameter is null.

Examples

The following example creates an attribute with unsigned integer content. It then retrieves the value by casting to UInt32.

XElement root = new XElement("Root",   
    new XAttribute("Att", 4294967295)  
);  
uint value = (uint)root.Attribute("Att");  
Console.WriteLine("value={0}", value);  
Dim root As XElement = <Root Att="4294967295"/>  
Dim value As UInteger = CUInt(root.Attribute("Att"))  
Console.WriteLine("value={0}", value)  

This example produces the following output:

value=4294967295  

See also

Applies to

Explicit(XAttribute to UInt64)

Source:
XAttribute.cs
Source:
XAttribute.cs
Source:
XAttribute.cs

Important

This API is not CLS-compliant.

Cast the value of this XAttribute to a UInt64.

public:
 static explicit operator System::UInt64(System::Xml::Linq::XAttribute ^ attribute);
[System.CLSCompliant(false)]
public static explicit operator ulong (System.Xml.Linq.XAttribute attribute);
[<System.CLSCompliant(false)>]
static member op_Explicit : System.Xml.Linq.XAttribute -> uint64
Public Shared Narrowing Operator CType (attribute As XAttribute) As ULong

Parameters

attribute
XAttribute

The XAttribute to cast to UInt64.

Returns

A UInt64 that contains the content of this XAttribute.

Attributes

Exceptions

The attribute does not contain a valid UInt64 value.

The attribute parameter is null.

Examples

The following example creates an attribute with unsigned long integer content. It then retrieves the value by casting to UInt64.

XElement root = new XElement("Root",  
    new XAttribute("Att", 1844674407370955161)  
);  
ulong value = (ulong)root.Attribute("Att");  
Console.WriteLine("value={0}", value);  
Dim root As XElement = <Root Att="1844674407370955161"/>  
Dim value As ULong = CULng(root.Attribute("Att"))  
Console.WriteLine("value={0}", value)  

This example produces the following output:

value=1844674407370955161  

See also

Applies to

Explicit(XAttribute to Single)

Source:
XAttribute.cs
Source:
XAttribute.cs
Source:
XAttribute.cs

Important

This API is not CLS-compliant.

Cast the value of this XAttribute to a Single.

public:
 static explicit operator float(System::Xml::Linq::XAttribute ^ attribute);
[System.CLSCompliant(false)]
public static explicit operator float (System.Xml.Linq.XAttribute attribute);
[<System.CLSCompliant(false)>]
static member op_Explicit : System.Xml.Linq.XAttribute -> single
Public Shared Narrowing Operator CType (attribute As XAttribute) As Single

Parameters

attribute
XAttribute

The XAttribute to cast to Single.

Returns

A Single that contains the content of this XAttribute.

Attributes

Exceptions

The attribute does not contain a valid Single value.

The attribute parameter is null.

Examples

The following example creates an attribute with single precision floating point content. It then retrieves the value by casting to Single.

XElement root = new XElement("Root",  
    new XAttribute("Att", 3.402823e38)  
);  
float value = (float)root.Attribute("Att");  
Console.WriteLine("value={0}", value);  
Dim root As XElement = <Root Att="3.402823E+38"/>  
Dim value As Single = CSng(root.Attribute("Att"))  
Console.WriteLine("value={0}", value)  

This example produces the following output:

value=3.402823E+38  

See also

Applies to

Explicit(XAttribute to Nullable<Guid>)

Source:
XAttribute.cs
Source:
XAttribute.cs
Source:
XAttribute.cs

Important

This API is not CLS-compliant.

Cast the value of this XAttribute to a Nullable<T> of Guid.

public:
 static explicit operator Nullable<Guid>(System::Xml::Linq::XAttribute ^ attribute);
[System.CLSCompliant(false)]
public static explicit operator Guid? (System.Xml.Linq.XAttribute attribute);
[System.CLSCompliant(false)]
public static explicit operator Guid? (System.Xml.Linq.XAttribute? attribute);
[<System.CLSCompliant(false)>]
static member op_Explicit : System.Xml.Linq.XAttribute -> Nullable<Guid>
Public Shared Narrowing Operator CType (attribute As XAttribute) As Nullable(Of Guid)

Parameters

attribute
XAttribute

The XAttribute to cast to a Nullable<T> of Guid.

Returns

A Nullable<T> of Guid that contains the content of this XAttribute.

Attributes

Exceptions

The attribute does not contain a valid Guid value.

Examples

The following example creates an attribute with guid content. It then retrieves the value by casting to Nullable<T> of Guid.

XElement root = new XElement("Root",  
    new XAttribute("Att", new Guid("3c1cc55b-baff-4b7a-9d17-077af3aa5730"))  
);  
Guid? value = (Guid?)root.Attribute("Att");  
Console.WriteLine("Nullable Guid: value={0}", value == null ? "null" : value.ToString());  
Dim root As XElement = <Root Att=<%= New Guid("3c1cc55b-baff-4b7a-9d17-077af3aa5730") %>/>  
Dim value As Nullable(Of Guid) = CType(root.Attribute("Att"), Nullable(Of Guid))  
Console.WriteLine("Nullable Guid: value={0}", IIf(value.HasValue, value.ToString(), "null"))  

This example produces the following output:

Nullable Guid: value=3c1cc55b-baff-4b7a-9d17-077af3aa5730  

See also

Applies to

Explicit(XAttribute to Nullable<Decimal>)

Source:
XAttribute.cs
Source:
XAttribute.cs
Source:
XAttribute.cs

Important

This API is not CLS-compliant.

Cast the value of this XAttribute to a Nullable<T> of Decimal.

public:
 static explicit operator Nullable<System::Decimal>(System::Xml::Linq::XAttribute ^ attribute);
[System.CLSCompliant(false)]
public static explicit operator decimal? (System.Xml.Linq.XAttribute attribute);
[System.CLSCompliant(false)]
public static explicit operator decimal? (System.Xml.Linq.XAttribute? attribute);
[<System.CLSCompliant(false)>]
static member op_Explicit : System.Xml.Linq.XAttribute -> Nullable<decimal>
Public Shared Narrowing Operator CType (attribute As XAttribute) As Nullable(Of Decimal)

Parameters

attribute
XAttribute

The XAttribute to cast to Nullable<T> of Decimal.

Returns

A Nullable<T> of Decimal that contains the content of this XAttribute.

Attributes

Exceptions

The attribute does not contain a valid Decimal value.

Examples

The following example creates an attribute with decimal content. It then retrieves the value by casting to Nullable<T> of Decimal.

XElement root = new XElement("Root",  
    new XAttribute("Att", "79228162514264337593543950335")  
);  
decimal? value = (decimal?)root.Attribute("Att");  
Console.WriteLine("Nullable decimal: value={0}", value == null ? "null" : value.ToString());  
Dim root As XElement = <Root Att="79228162514264337593543950335"/>  
Dim value As Nullable(Of Decimal) = CType(root.Attribute("Att"), Nullable(Of Decimal))  
Console.WriteLine("Nullable decimal: value={0}", IIf(value.HasValue, value.ToString(), "null"))  

This example produces the following output:

Nullable decimal: value=79228162514264337593543950335  

See also

Applies to

Explicit(XAttribute to Decimal)

Source:
XAttribute.cs
Source:
XAttribute.cs
Source:
XAttribute.cs

Important

This API is not CLS-compliant.

Cast the value of this XAttribute to a Decimal.

public:
 static explicit operator System::Decimal(System::Xml::Linq::XAttribute ^ attribute);
[System.CLSCompliant(false)]
public static explicit operator decimal (System.Xml.Linq.XAttribute attribute);
[<System.CLSCompliant(false)>]
static member op_Explicit : System.Xml.Linq.XAttribute -> decimal
Public Shared Narrowing Operator CType (attribute As XAttribute) As Decimal

Parameters

attribute
XAttribute

The XAttribute to cast to Decimal.

Returns

A Decimal that contains the content of this XAttribute.

Attributes

Exceptions

The attribute does not contain a valid Decimal value.

The attribute parameter is null.

Examples

The following example creates an attribute with a decimal value. It then retrieves the value of the attribute by casting to Decimal.

XElement root = new XElement("Root",  
    new XAttribute("Att", "79228162514264337593543950335")  
);  
decimal value = (decimal)root.Attribute("Att");  
Console.WriteLine("value={0}", value);  
Dim root As XElement = <Root Att="79228162514264337593543950335"/>  
Dim value As Decimal = CDec(root.Attribute("Att"))  
Console.WriteLine("value={0}", value)  

This example produces the following output:

value=79228162514264337593543950335  

See also

Applies to

Explicit(XAttribute to Nullable<DateTimeOffset>)

Source:
XAttribute.cs
Source:
XAttribute.cs
Source:
XAttribute.cs

Important

This API is not CLS-compliant.

Cast the value of this XAttribute to a Nullable<T> of DateTimeOffset.

public:
 static explicit operator Nullable<DateTimeOffset>(System::Xml::Linq::XAttribute ^ attribute);
[System.CLSCompliant(false)]
public static explicit operator DateTimeOffset? (System.Xml.Linq.XAttribute attribute);
[System.CLSCompliant(false)]
public static explicit operator DateTimeOffset? (System.Xml.Linq.XAttribute? attribute);
[<System.CLSCompliant(false)>]
static member op_Explicit : System.Xml.Linq.XAttribute -> Nullable<DateTimeOffset>
Public Shared Narrowing Operator CType (attribute As XAttribute) As Nullable(Of DateTimeOffset)

Parameters

attribute
XAttribute

The XAttribute to cast to a Nullable<T> of DateTimeOffset.

Returns

A Nullable<T> of DateTimeOffset that contains the content of this XAttribute.

Attributes

Exceptions

The attribute does not contain a valid DateTimeOffset value.

Examples

The following example creates an attribute with a date and time as content. It then retrieves the value by casting to Nullable<T> of DateTimeOffset.

XElement root = new XElement("Root",  
    new XAttribute("Att", new DateTimeOffset(new DateTime(2006, 10, 6, 12, 30, 0)))  
);  
DateTimeOffset? value = (DateTimeOffset?)root.Attribute("Att");  
Console.WriteLine("Nullable DateTimeOffset: value={0}", value == null ? "null" : value.ToString());  
Dim root As XElement = _  
    <Root  
        Att=<%= New DateTimeOffset(New DateTime(2006, 10, 6, 12, 30, 0)) %>/>  
Dim value As Nullable(Of DateTimeOffset) = CType(root.Attribute("Att"), Nullable(Of DateTimeOffset))  
Console.WriteLine("Nullable DateTimeOffset: value={0}", IIf(value.HasValue, value.ToString(), "null"))  

This example produces the following output:

Nullable DateTimeOffset: value=10/6/2006 12:30:00 PM -07:00  

Remarks

This conversion operator uses the XmlConvert class to do the conversion.

Applies to

Explicit(XAttribute to Nullable<DateTime>)

Source:
XAttribute.cs
Source:
XAttribute.cs
Source:
XAttribute.cs

Important

This API is not CLS-compliant.

Cast the value of this XAttribute to a Nullable<T> of DateTime.

public:
 static explicit operator Nullable<DateTime>(System::Xml::Linq::XAttribute ^ attribute);
[System.CLSCompliant(false)]
public static explicit operator DateTime? (System.Xml.Linq.XAttribute attribute);
[System.CLSCompliant(false)]
public static explicit operator DateTime? (System.Xml.Linq.XAttribute? attribute);
[<System.CLSCompliant(false)>]
static member op_Explicit : System.Xml.Linq.XAttribute -> Nullable<DateTime>
Public Shared Narrowing Operator CType (attribute As XAttribute) As Nullable(Of DateTime)

Parameters

attribute
XAttribute

The XAttribute to cast to a Nullable<T> of DateTime.

Returns

A Nullable<T> of DateTime that contains the content of this XAttribute.

Attributes

Exceptions

The attribute does not contain a valid DateTime value.

Examples

The following example creates an attribute with a date and time as content. It then retrieves the value by casting to Nullable<T> of DateTime.

XElement root = new XElement("Root",  
    new XAttribute("Att", new DateTime(2006, 10, 6, 12, 30, 0))  
);  
DateTime? value = (DateTime?)root.Attribute("Att");  
Console.WriteLine("Nullable DateTime: value={0}", value == null ? "null" : value.ToString());  
Dim root As XElement = <Root Att=<%= New DateTime(2006, 10, 6, 12, 30, 0) %>/>  
Dim value As Nullable(Of DateTime) = CType(root.Attribute("Att"), Nullable(Of DateTime))  
Console.WriteLine("Nullable DateTime: value={0}", IIf(value.HasValue, value.ToString(), "null"))  

This example produces the following output:

Nullable DateTime: value=10/6/2006 12:30:00 PM  

Remarks

The value space of an attribute or element that contains date and time content is closely related to the dates and times described in ISO 8601. When creating an attribute or element that contains date and time content, the attribute or element values are formatted per the W3C specification. See the W3C specification for more details.

Behavior is lax when casting to a Nullable<T> of DateTime from an attribute or element. Even if the attribute or element value is not formatted exactly per the W3C specification, the value is appropriately converted to a Nullable<T> of DateTime.

This conversion operator uses CultureInfo.InvariantCulture to convert from a DateTime.

See also

Applies to

Explicit(XAttribute to Nullable<Boolean>)

Source:
XAttribute.cs
Source:
XAttribute.cs
Source:
XAttribute.cs

Important

This API is not CLS-compliant.

Cast the value of this XAttribute to a Nullable<T> of Boolean.

public:
 static explicit operator Nullable<bool>(System::Xml::Linq::XAttribute ^ attribute);
[System.CLSCompliant(false)]
public static explicit operator bool? (System.Xml.Linq.XAttribute attribute);
[System.CLSCompliant(false)]
public static explicit operator bool? (System.Xml.Linq.XAttribute? attribute);
[<System.CLSCompliant(false)>]
static member op_Explicit : System.Xml.Linq.XAttribute -> Nullable<bool>
Public Shared Narrowing Operator CType (attribute As XAttribute) As Nullable(Of Boolean)

Parameters

attribute
XAttribute

The XAttribute to cast to Nullable<T> of Boolean.

Returns

A Nullable<T> of Boolean that contains the content of this XAttribute.

Attributes

Exceptions

The attribute does not contain a valid Boolean value.

Examples

The following example creates an attribute with Boolean content. It then retrieves the value by casting to Nullable<T> of Boolean.

XElement root = new XElement("Root",   
    new XAttribute("BoolValue1", true),  
    new XAttribute("BoolValue2", false)  
);  
bool? bool1 = (bool?)root.Attribute("BoolValue1");  
bool? bool2 = (bool?)root.Attribute("BoolValue2");  
Console.WriteLine("Nullable boolean: BoolValue1={0}", bool1);  
Console.WriteLine("Nullable boolean: BoolValue2={0}", bool2);  
Dim root As XElement = <Root BoolValue1="true" BoolValue2="false"/>  
Dim bool1 As Nullable(Of Boolean) = CType(root.Attribute("BoolValue1"), Nullable(Of Boolean))  
Dim bool2 As Nullable(Of Boolean) = CType(root.Attribute("BoolValue2"), Nullable(Of Boolean))  
Console.WriteLine("Nullable boolean: BoolValue1={0}", bool1)  
Console.WriteLine("Nullable boolean: BoolValue2={0}", bool2)  

This example produces the following output:

Nullable boolean: BoolValue1=True  
Nullable boolean: BoolValue2=False  

Remarks

When converting to Boolean from an attribute or element, allowed values are "0", "1", and any string that produces "true" or "false" after trimming and conversion to lower case.

See also

Applies to

Explicit(XAttribute to Int64)

Source:
XAttribute.cs
Source:
XAttribute.cs
Source:
XAttribute.cs

Important

This API is not CLS-compliant.

Cast the value of this XAttribute to an Int64.

public:
 static explicit operator long(System::Xml::Linq::XAttribute ^ attribute);
[System.CLSCompliant(false)]
public static explicit operator long (System.Xml.Linq.XAttribute attribute);
[<System.CLSCompliant(false)>]
static member op_Explicit : System.Xml.Linq.XAttribute -> int64
Public Shared Narrowing Operator CType (attribute As XAttribute) As Long

Parameters

attribute
XAttribute

The XAttribute to cast to Int64.

Returns

A Int64 that contains the content of this XAttribute.

Attributes

Exceptions

The attribute does not contain a valid Int64 value.

The attribute parameter is null.

Examples

The following example creates an attribute with a long integer as content. It then retrieves the value of the attribute by casting to Int64.

XElement root = new XElement("Root",  
    new XAttribute("Att", 9223372036854775807)  
);  
long value = (long)root.Attribute("Att");  
Console.WriteLine("value={0}", value);  
Dim root As XElement = <Root Att="9223372036854775807"/>  
Dim value As Long = CLng(root.Attribute("Att"))  
Console.WriteLine("value={0}", value)  

This example produces the following output:

value=9223372036854775807  

See also

Applies to

Explicit(XAttribute to Int32)

Source:
XAttribute.cs
Source:
XAttribute.cs
Source:
XAttribute.cs

Important

This API is not CLS-compliant.

Cast the value of this XAttribute to an Int32.

public:
 static explicit operator int(System::Xml::Linq::XAttribute ^ attribute);
[System.CLSCompliant(false)]
public static explicit operator int (System.Xml.Linq.XAttribute attribute);
[<System.CLSCompliant(false)>]
static member op_Explicit : System.Xml.Linq.XAttribute -> int
Public Shared Narrowing Operator CType (attribute As XAttribute) As Integer

Parameters

attribute
XAttribute

The XAttribute to cast to Int32.

Returns

A Int32 that contains the content of this XAttribute.

Attributes

Exceptions

The attribute does not contain a valid Int32 value.

The attribute parameter is null.

Examples

The following example creates an attribute with an integer as content. It then retrieves the value by casting to Int32.

XElement root = new XElement("Root",  
    new XAttribute("Att", 2147483647)  
);  
int value = (int)root.Attribute("Att");  
Console.WriteLine("value={0}", value);  
Dim root As XElement = <Root Att="2147483647"/>  
Dim value As Integer = CInt(root.Attribute("Att"))  
Console.WriteLine("value={0}", value)  

This example produces the following output:

value=2147483647  

See also

Applies to

Explicit(XAttribute to Guid)

Source:
XAttribute.cs
Source:
XAttribute.cs
Source:
XAttribute.cs

Important

This API is not CLS-compliant.

Cast the value of this XAttribute to a Guid.

public:
 static explicit operator Guid(System::Xml::Linq::XAttribute ^ attribute);
[System.CLSCompliant(false)]
public static explicit operator Guid (System.Xml.Linq.XAttribute attribute);
[<System.CLSCompliant(false)>]
static member op_Explicit : System.Xml.Linq.XAttribute -> Guid
Public Shared Narrowing Operator CType (attribute As XAttribute) As Guid

Parameters

attribute
XAttribute

The XAttribute to cast to Guid.

Returns

A Guid that contains the content of this XAttribute.

Attributes

Exceptions

The attribute does not contain a valid Guid value.

The attribute parameter is null.

Examples

The following example creates an attribute with a GUID as content. It then retrieves the value by casting to Guid.

XElement root = new XElement("Root",  
    new XAttribute("Att", new Guid("3c1cc55b-baff-4b7a-9d17-077af3aa5730"))  
);  
Guid value = (Guid)root.Attribute("Att");  
Console.WriteLine("value={0}", value);  
Dim root As XElement = <Root Att=<%= New Guid("3c1cc55b-baff-4b7a-9d17-077af3aa5730") %>/>  
Dim value As Guid = CType(root.Attribute("Att"), Guid)  
Console.WriteLine("value={0}", value)  

This example produces the following output:

value=3c1cc55b-baff-4b7a-9d17-077af3aa5730  

See also

Applies to

Explicit(XAttribute to Double)

Source:
XAttribute.cs
Source:
XAttribute.cs
Source:
XAttribute.cs

Important

This API is not CLS-compliant.

Cast the value of this XAttribute to a Double.

public:
 static explicit operator double(System::Xml::Linq::XAttribute ^ attribute);
[System.CLSCompliant(false)]
public static explicit operator double (System.Xml.Linq.XAttribute attribute);
[<System.CLSCompliant(false)>]
static member op_Explicit : System.Xml.Linq.XAttribute -> double
Public Shared Narrowing Operator CType (attribute As XAttribute) As Double

Parameters

attribute
XAttribute

The XAttribute to cast to Double.

Returns

A Double that contains the content of this XAttribute.

Attributes

Exceptions

The attribute does not contain a valid Double value.

The attribute parameter is null.

Examples

The following example creates an attribute with Double content. It then retrieves the value by casting to Double.

XElement root = new XElement("Root",  
    new XAttribute("Att", 1.79769313486231e308)  
);  
double value = (double)root.Attribute("Att");  
Console.WriteLine("value={0}", value);  
Dim root As XElement = <Root Att="1.79769313486231E+308"/>  
Dim value As Double = CDbl(root.Attribute("Att"))  
Console.WriteLine("value={0}", value)  

This example produces the following output:

value=1.79769313486231E+308  

See also

Applies to

Explicit(XAttribute to Nullable<Double>)

Source:
XAttribute.cs
Source:
XAttribute.cs
Source:
XAttribute.cs

Important

This API is not CLS-compliant.

Cast the value of this XAttribute to a Nullable<T> of Double.

public:
 static explicit operator Nullable<double>(System::Xml::Linq::XAttribute ^ attribute);
[System.CLSCompliant(false)]
public static explicit operator double? (System.Xml.Linq.XAttribute attribute);
[System.CLSCompliant(false)]
public static explicit operator double? (System.Xml.Linq.XAttribute? attribute);
[<System.CLSCompliant(false)>]
static member op_Explicit : System.Xml.Linq.XAttribute -> Nullable<double>
Public Shared Narrowing Operator CType (attribute As XAttribute) As Nullable(Of Double)

Parameters

attribute
XAttribute

The XAttribute to cast to Nullable<T> of Double.

Returns

A Nullable<T> of Double that contains the content of this XAttribute.

Attributes

Exceptions

The attribute does not contain a valid Double value.

Examples

The following example creates an attribute with double precision floating point content. It then retrieves the value by casting to Nullable<T> of Double.

XElement root = new XElement("Root",  
    new XAttribute("Att", 1.79769313486231e308)  
);  
double? value = (double?)root.Attribute("Att");  
Console.WriteLine("Nullable double: value={0}", value == null ? "null" : value.ToString());  
Dim root As XElement = <Root Att="1.79769313486231E+308"/>  
Dim value As Nullable(Of Double) = CType(root.Attribute("Att"), Nullable(Of Double))  
Console.WriteLine("Nullable double: value={0}", IIf(value.HasValue, value.ToString(), "null"))  

This example produces the following output:

Nullable double: value=1.79769313486231E+308  

See also

Applies to

Explicit(XAttribute to DateTimeOffset)

Source:
XAttribute.cs
Source:
XAttribute.cs
Source:
XAttribute.cs

Important

This API is not CLS-compliant.

Cast the value of this XAttribute to a DateTimeOffset.

public:
 static explicit operator DateTimeOffset(System::Xml::Linq::XAttribute ^ attribute);
[System.CLSCompliant(false)]
public static explicit operator DateTimeOffset (System.Xml.Linq.XAttribute attribute);
[<System.CLSCompliant(false)>]
static member op_Explicit : System.Xml.Linq.XAttribute -> DateTimeOffset
Public Shared Narrowing Operator CType (attribute As XAttribute) As DateTimeOffset

Parameters

attribute
XAttribute

The XAttribute to cast to DateTimeOffset.

Returns

A DateTimeOffset that contains the content of this XAttribute.

Attributes

Exceptions

The attribute does not contain a valid DateTimeOffset value.

The attribute parameter is null.

Examples

The following example creates an attribute with date and time content. It then casts it to DateTimeOffset to retrieve the value.

XElement root = new XElement("Root",  
    new XAttribute("Att", new DateTimeOffset(new DateTime(2006, 10, 6, 12, 30, 0)))  
);  
Console.WriteLine(root);  

// casting from a strictly formatted XML attribute  
DateTimeOffset dt = (DateTimeOffset)root.Attribute("Att");  
Console.WriteLine("dt={0}", dt);  
Dim root As XElement = _  
    <Root  
        Att=<%= New DateTimeOffset(New DateTime(2006, 10, 6, 12, 30, 0)) %>/>  
Console.WriteLine(root)  

' casting from a strictly formatted XML attribute  
Dim dt As DateTimeOffset = CType(root.Attribute("Att"), DateTimeOffset)  
Console.WriteLine("dt={0}", dt)  

This example produces the following output:

<Root Att="2006-10-06T12:30:00-07:00" />  
dt=10/6/2006 12:30:00 PM -07:00  

Remarks

This conversion operator uses the XmlConvert class to do the conversion.

See also

Applies to

Explicit(XAttribute to DateTime)

Source:
XAttribute.cs
Source:
XAttribute.cs
Source:
XAttribute.cs

Important

This API is not CLS-compliant.

Cast the value of this XAttribute to a DateTime.

public:
 static explicit operator DateTime(System::Xml::Linq::XAttribute ^ attribute);
[System.CLSCompliant(false)]
public static explicit operator DateTime (System.Xml.Linq.XAttribute attribute);
[<System.CLSCompliant(false)>]
static member op_Explicit : System.Xml.Linq.XAttribute -> DateTime
Public Shared Narrowing Operator CType (attribute As XAttribute) As DateTime

Parameters

attribute
XAttribute

The XAttribute to cast to DateTime.

Returns

A DateTime that contains the content of this XAttribute.

Attributes

Exceptions

The attribute does not contain a valid DateTime value.

The attribute parameter is null.

Examples

The following example creates an attribute with date and time content. It then casts it to DateTime to retrieve the value.

// Behavior is strict when formatting an XML element or attribute from a DateTime,  
// but behavior is lax when casting to a DateTime from an element or attribute.  

XElement root = new XElement("Root",  
    new XAttribute("Att", new DateTime(2006, 10, 6, 12, 30, 0))  
);  
Console.WriteLine(root);  

// casting from a strictly formatted XML attribute  
DateTime dt = (DateTime)root.Attribute("Att");  
Console.WriteLine("dt={0}", dt);  
Console.WriteLine("-----");  

// if root is formatted in some different way than the standard ISO 8601, if at all possible,  
// the value is appropriately converted to DateTime  

XAttribute dtAtt = new XAttribute("OrderDate", "October 6, 2006");  
Console.WriteLine(dtAtt);  
DateTime orderDate = (DateTime)dtAtt;  
Console.WriteLine("OrderDate={0:d}", orderDate);  
' Behavior is strict when formatting an XML element or attribute from a DateTime,  
' but behavior is lax when casting to a DateTime from an element or attribute.  
Dim root As XElement = <Root Att=<%= New DateTime(2006, 10, 6, 12, 30, 0) %>/>  

Console.WriteLine(root)  

' casting from a strictly formatted XML attribute  
Dim dt As DateTime = CType(root.Attribute("Att"), DateTime)  
Console.WriteLine("dt={0}", dt)  
Console.WriteLine("-----")  

' if root is formatted in some different way than the standard ISO 8601, if at all possible,  
' the value is appropriately converted to DateTime  
Dim dtAtt As XAttribute = New XAttribute("OrderDate", "October 6, 2006")  
Console.WriteLine(dtAtt)  
Dim orderDate As DateTime = CType(dtAtt, DateTime)  
Console.WriteLine("OrderDate={0:d}", orderDate)  

This example produces the following output:

<Root Att="2006-10-06T12:30:00" />  
dt=10/6/2006 12:30:00 PM  
-----  
OrderDate="October 6, 2006"  
OrderDate=10/6/2006  

Remarks

The value space of an attribute or element that contains date and time content is closely related to the dates and times described in ISO 8601. When creating an attribute or element that contains date and time content, the attribute or element values are formatted per the W3C specification. See the W3C specification for more details.

Behavior is lax when casting to a DateTime from an attribute or element. Even if the attribute or element value is not formatted exactly per the W3C specification, the value is appropriately converted to a DateTime.

This conversion operator uses CultureInfo.InvariantCulture to convert from a DateTime.

See also

Applies to

Explicit(XAttribute to Boolean)

Source:
XAttribute.cs
Source:
XAttribute.cs
Source:
XAttribute.cs

Important

This API is not CLS-compliant.

Cast the value of this XAttribute to a Boolean.

public:
 static explicit operator bool(System::Xml::Linq::XAttribute ^ attribute);
[System.CLSCompliant(false)]
public static explicit operator bool (System.Xml.Linq.XAttribute attribute);
[<System.CLSCompliant(false)>]
static member op_Explicit : System.Xml.Linq.XAttribute -> bool
Public Shared Narrowing Operator CType (attribute As XAttribute) As Boolean

Parameters

attribute
XAttribute

The XAttribute to cast to Boolean.

Returns

A Boolean that contains the content of this XAttribute.

Attributes

Exceptions

The attribute does not contain a valid Boolean value.

The attribute parameter is null.

Examples

The following example creates an attribute with a Boolean value, then casts it to Boolean.

XElement root = new XElement("Root",   
    new XAttribute("BoolValue", true)  
);  
bool bv = (bool)root.Attribute("BoolValue");  
Console.WriteLine("(bool)BoolValue={0}", bv);  
Dim root As XElement = <root BoolValue="true"/>  
Dim bv As Boolean = CBool(root.Attribute("BoolValue"))  
Console.WriteLine("(bool)BoolValue={0}", bv)  

This example produces the following output:

(bool)BoolValue=True  

Remarks

When converting to Boolean from an attribute or element, allowed values are "0", "1", and any string that produces "true" or "false" after trimming and conversion to lower case.

See also

Applies to