XElement.Explicit Operator

Definition

Överlagringar

Name Description
Explicit(XElement to Nullable<Int64>)

Omvandla värdet för detta XElement till en Nullable<T> av Int64.

Explicit(XElement to Nullable<Single>)

Omvandla värdet för detta XElement till en Nullable<T> av Single.

Explicit(XElement to Nullable<TimeSpan>)

Omvandla värdet för detta XElement till en Nullable<T> av TimeSpan.

Explicit(XElement to Nullable<UInt32>)

Omvandla värdet för detta XElement till en Nullable<T> av UInt32.

Explicit(XElement to Nullable<UInt64>)

Omvandla värdet för detta XElement till en Nullable<T> av UInt64.

Explicit(XElement to UInt32)

Omvandla värdet för detta XElement till en UInt32.

Explicit(XElement to String)

Omvandla värdet för detta XElement till en String.

Explicit(XElement to TimeSpan)

Omvandla värdet för detta XElement till en TimeSpan.

Explicit(XElement to UInt64)

Omvandla värdet för detta XElement till en UInt64.

Explicit(XElement to Nullable<Int32>)

Omvandla värdet för detta XElement till en Nullable<T> av Int32.

Explicit(XElement to Single)

Omvandla värdet för detta XElement till en Single.

Explicit(XElement to Nullable<Guid>)

Omvandla värdet för detta XElement till en Nullable<T> av Guid.

Explicit(XElement to Nullable<Boolean>)

Omvandla värdet för detta XElement till en Nullable<T> av Boolean.

Explicit(XElement to Nullable<Decimal>)

Omvandla värdet för detta XElement till en Nullable<T> av Decimal.

Explicit(XElement to Boolean)

Omvandla värdet för detta XElement till en Boolean.

Explicit(XElement to DateTime)

Omvandla värdet för detta XElement till en DateTime.

Explicit(XElement to DateTimeOffset)

Omvandla värdet för detta XAttribute till en DateTimeOffset.

Explicit(XElement to Double)

Omvandla värdet för detta XElement till en Double.

Explicit(XElement to Guid)

Omvandla värdet för detta XElement till en Guid.

Explicit(XElement to Decimal)

Omvandla värdet för detta XElement till en Decimal.

Explicit(XElement to Int64)

Omvandla värdet för detta XElement till en Int64.

Explicit(XElement to Nullable<Double>)

Omvandla värdet för detta XElement till en Nullable<T> av Double.

Explicit(XElement to Nullable<DateTime>)

Omvandla värdet för detta XElement till en Nullable<T> av DateTime.

Explicit(XElement to Nullable<DateTimeOffset>)

Omvandla värdet för detta XElement till en Nullable<T> av DateTimeOffset.

Explicit(XElement to Int32)

Omvandla värdet för detta XElement till en Int32.

Explicit(XElement to Nullable<Int64>)

Källa:
XElement.cs
Källa:
XElement.cs
Källa:
XElement.cs
Källa:
XElement.cs
Källa:
XElement.cs

Viktigt!

Detta API uppfyller inte CLS.

Omvandla värdet för detta XElement till en Nullable<T> av Int64.

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

Parametrar

element
XElement

Att XElement kasta till Nullable<T> av Int64.

Returer

En Nullable<T> av Int64 dessa innehåller innehållet i den här XElement.

Attribut

Undantag

Elementet är inte null och innehåller inget giltigt Int64 värde.

Exempel

I följande exempel skapas ett element med långt heltalsinnehåll. Det hämtar sedan värdet genom att gjuta till av Nullable<T>Int64.

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

Det här exemplet genererar följande utdata:

Nullable ulong: value=9223372036854775807

Se även

Gäller för

Explicit(XElement to Nullable<Single>)

Källa:
XElement.cs
Källa:
XElement.cs
Källa:
XElement.cs
Källa:
XElement.cs
Källa:
XElement.cs

Viktigt!

Detta API uppfyller inte CLS.

Omvandla värdet för detta XElement till en Nullable<T> av Single.

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

Parametrar

element
XElement

Att XElement kasta till Nullable<T> av Single.

Returer

En Nullable<T> av Single dessa innehåller innehållet i den här XElement.

Attribut

Undantag

Elementet är inte null och innehåller inget giltigt Single värde.

Exempel

I följande exempel skapas ett element med flyttalsinnehåll med enkel precision. Det hämtar sedan värdet genom att gjuta till av Nullable<T>Single.

XElement root = new XElement("Root",
    new XElement("Value", 3.402823e38)
);
float? value = (float?)root.Element("Value");
Console.WriteLine("Nullable Single: value={0}", value == null ? "null" : value.ToString());
Dim root As XElement = _
        <Root>
            <Value>3.402823e38</Value>
        </Root>
Dim value As Nullable(Of Single) = CType(root.Element("Value"), Nullable(Of Single))
Console.WriteLine("Nullable Single: value={0}", IIf(value.HasValue, value.ToString(), "null"))

Det här exemplet genererar följande utdata:

Nullable Single: value=3.402823E+38

Se även

Gäller för

Explicit(XElement to Nullable<TimeSpan>)

Källa:
XElement.cs
Källa:
XElement.cs
Källa:
XElement.cs
Källa:
XElement.cs
Källa:
XElement.cs

Viktigt!

Detta API uppfyller inte CLS.

Omvandla värdet för detta XElement till en Nullable<T> av TimeSpan.

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

Parametrar

element
XElement

Att XElement kasta till Nullable<T> av TimeSpan.

Returer

En Nullable<T> av TimeSpan dessa innehåller innehållet i den här XElement.

Attribut

Undantag

Elementet är inte null och innehåller inget giltigt TimeSpan värde.

Exempel

I följande exempel skapas ett element med tidsintervallinnehåll. Det hämtar sedan värdet genom att gjuta till av Nullable<T>TimeSpan.

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

Det här exemplet genererar följande utdata:

Nullable TimeSpan: value=01:05:30

Kommentarer

Värdeutrymmet för ett attribut eller element som innehåller tidsintervallinnehåll är nära relaterat till varaktighetsinnehåll enligt beskrivningen i ISO 8601. När du skapar ett attribut eller element som innehåller tidsintervallsinnehåll formateras attribut- eller elementvärdena enligt W3C-specifikationen. Mer information finns i W3C-specifikationen.

Beteendet är slappt vid gjutning till ett Nullable<T> av TimeSpan från ett attribut eller element. Även om attributet eller elementvärdet inte är exakt formaterat enligt W3C-specifikationen konverteras värdet korrekt till en Nullable<T> av TimeSpan.

Se även

Gäller för

Explicit(XElement to Nullable<UInt32>)

Källa:
XElement.cs
Källa:
XElement.cs
Källa:
XElement.cs
Källa:
XElement.cs
Källa:
XElement.cs

Viktigt!

Detta API uppfyller inte CLS.

Omvandla värdet för detta XElement till en Nullable<T> av UInt32.

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

Parametrar

element
XElement

Att XElement kasta till Nullable<T> av UInt32.

Returer

En Nullable<T> av UInt32 dessa innehåller innehållet i den här XElement.

Attribut

Undantag

Elementet är inte null och innehåller inget giltigt UInt32 värde.

Exempel

I följande exempel skapas ett element med osignerat heltalsinnehåll. Det hämtar sedan värdet genom att gjuta till av Nullable<T>UInt32.

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

Det här exemplet genererar följande utdata:

Nullable uint: value=4294967295

Se även

Gäller för

Explicit(XElement to Nullable<UInt64>)

Källa:
XElement.cs
Källa:
XElement.cs
Källa:
XElement.cs
Källa:
XElement.cs
Källa:
XElement.cs

Viktigt!

Detta API uppfyller inte CLS.

Omvandla värdet för detta XElement till en Nullable<T> av UInt64.

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

Parametrar

element
XElement

Att XElement kasta till Nullable<T> av UInt64.

Returer

En Nullable<T> av UInt64 dessa innehåller innehållet i den här XElement.

Attribut

Undantag

Elementet är inte null och innehåller inget giltigt UInt64 värde.

Exempel

I följande exempel skapas ett element med osignerat långt heltalsinnehåll. Det hämtar sedan värdet genom att gjuta till av Nullable<T>UInt64.

XElement root = new XElement("Root",
    new XElement("Value", 9223372036854775807)
);
ulong? value = (ulong?)root.Element("Value");
Console.WriteLine("Nullable ulong: value={0}", value == null ? "null" : value.ToString());
Dim root As XElement = _
        <Root>
            <Value>9223372036854775807</Value>
        </Root>

Dim value As Nullable(Of ULong) = CType(root.Element("Value"), Nullable(Of ULong))
Console.WriteLine("Nullable ulong: value={0}", IIf(value.HasValue, value.ToString(), "null"))

Det här exemplet genererar följande utdata:

Nullable ulong: value=9223372036854775807

Se även

Gäller för

Explicit(XElement to UInt32)

Källa:
XElement.cs
Källa:
XElement.cs
Källa:
XElement.cs
Källa:
XElement.cs
Källa:
XElement.cs

Viktigt!

Detta API uppfyller inte CLS.

Omvandla värdet för detta XElement till en UInt32.

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

Parametrar

element
XElement

Att XElement kasta till UInt32.

Returer

En UInt32 som innehåller innehållet i den här XElement.

Attribut

Undantag

Elementet innehåller inget giltigt UInt32 värde.

Parametern element är null.

Exempel

I följande exempel skapas ett element med osignerat heltalsinnehåll. Det hämtar sedan värdet genom att gjuta till UInt32.

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

Det här exemplet genererar följande utdata:

value=4294967295

Se även

Gäller för

Explicit(XElement to String)

Källa:
XElement.cs
Källa:
XElement.cs
Källa:
XElement.cs
Källa:
XElement.cs
Källa:
XElement.cs

Viktigt!

Detta API uppfyller inte CLS.

Omvandla värdet för detta XElement till en String.

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

Parametrar

element
XElement

Att XElement kasta till String.

Returer

En String som innehåller innehållet i den här XElement.

Attribut

Exempel

I följande exempel skapas ett element med stränginnehåll. Det hämtar sedan värdet genom att gjuta till String.

XElement root = XElement.Parse("<Root>abc <b>def </b>ghi</Root>");
Console.WriteLine("(string)root={0}", (string)root);
Dim root As XElement = <Root>abc <b>def </b>ghi</Root>
Console.WriteLine("(string)root={0}", root.Value)

Det här exemplet genererar följande utdata:

(string)root=abc def ghi

Kommentarer

Om har XElement underordnade värden returneras det sammanfogade strängvärdet för all elementtext och underordnad text.

Se även

Gäller för

Explicit(XElement to TimeSpan)

Källa:
XElement.cs
Källa:
XElement.cs
Källa:
XElement.cs
Källa:
XElement.cs
Källa:
XElement.cs

Viktigt!

Detta API uppfyller inte CLS.

Omvandla värdet för detta XElement till en TimeSpan.

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

Parametrar

element
XElement

Att XElement kasta till TimeSpan.

Returer

En TimeSpan som innehåller innehållet i den här XElement.

Attribut

Undantag

Elementet innehåller inget giltigt TimeSpan värde.

Parametern element är null.

Exempel

I följande exempel skapas ett element med tidsintervallinnehåll. Det hämtar sedan värdet genom att gjuta till TimeSpan.

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

Det här exemplet genererar följande utdata:

value=01:05:30

Kommentarer

Värdeutrymmet för ett attribut eller element som innehåller tidsintervallinnehåll är nära relaterat till varaktighetsinnehåll enligt beskrivningen i ISO 8601. När du skapar ett attribut eller element som innehåller tidsintervallsinnehåll formateras attribut- eller elementvärdena enligt W3C-specifikationen. Mer information finns i W3C-specifikationen.

Beteendet är släpphänt vid gjutning till ett TimeSpan från ett attribut eller element. Även om attributet eller elementvärdet inte formateras exakt enligt W3C-specifikationen konverteras värdet korrekt till en TimeSpan.

Se även

Gäller för

Explicit(XElement to UInt64)

Källa:
XElement.cs
Källa:
XElement.cs
Källa:
XElement.cs
Källa:
XElement.cs
Källa:
XElement.cs

Viktigt!

Detta API uppfyller inte CLS.

Omvandla värdet för detta XElement till en UInt64.

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

Parametrar

element
XElement

Att XElement kasta till UInt64.

Returer

En UInt64 som innehåller innehållet i den här XElement.

Attribut

Undantag

Elementet innehåller inget giltigt UInt64 värde.

Parametern element är null.

element är null.

Exempel

I följande exempel skapas ett element med osignerat långt heltalsinnehåll. Det hämtar sedan värdet genom att gjuta till UInt64.

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

Det här exemplet genererar följande utdata:

value=18446744073709551615

Se även

Gäller för

Explicit(XElement to Nullable<Int32>)

Källa:
XElement.cs
Källa:
XElement.cs
Källa:
XElement.cs
Källa:
XElement.cs
Källa:
XElement.cs

Viktigt!

Detta API uppfyller inte CLS.

Omvandla värdet för detta XElement till en Nullable<T> av Int32.

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

Parametrar

element
XElement

Att XElement kasta till Nullable<T> av Int32.

Returer

En Nullable<T> av Int32 dessa innehåller innehållet i den här XElement.

Attribut

Undantag

Elementet är inte null och innehåller inget giltigt Int32 värde.

Exempel

I följande exempel skapas ett element med osignerat heltalsinnehåll. Det hämtar sedan värdet genom att gjuta till av Nullable<T>Int32.

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

Det här exemplet genererar följande utdata:

Nullable integer: value=2147483647

Se även

Gäller för

Explicit(XElement to Single)

Källa:
XElement.cs
Källa:
XElement.cs
Källa:
XElement.cs
Källa:
XElement.cs
Källa:
XElement.cs

Viktigt!

Detta API uppfyller inte CLS.

Omvandla värdet för detta XElement till en Single.

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

Parametrar

element
XElement

Att XElement kasta till Single.

Returer

En Single som innehåller innehållet i den här XElement.

Attribut

Undantag

Elementet innehåller inget giltigt Single värde.

Parametern element är null.

element är null.

Exempel

I följande exempel skapas ett element med flyttalsinnehåll med enkel precision. Det hämtar sedan värdet genom att gjuta till Single.

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

Det här exemplet genererar följande utdata:

value=3.402823E+38

Se även

Gäller för

Explicit(XElement to Nullable<Guid>)

Källa:
XElement.cs
Källa:
XElement.cs
Källa:
XElement.cs
Källa:
XElement.cs
Källa:
XElement.cs

Viktigt!

Detta API uppfyller inte CLS.

Omvandla värdet för detta XElement till en Nullable<T> av Guid.

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

Parametrar

element
XElement

Att XElement kasta till Nullable<T> av Guid.

Returer

En Nullable<T> av Guid dessa innehåller innehållet i den här XElement.

Attribut

Undantag

Elementet är inte null och innehåller inget giltigt Guid värde.

Exempel

I följande exempel skapas ett element med guid-innehåll. Det hämtar sedan värdet genom att gjuta till av Nullable<T>Guid.

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

Det här exemplet genererar följande utdata:

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

Se även

Gäller för

Explicit(XElement to Nullable<Boolean>)

Källa:
XElement.cs
Källa:
XElement.cs
Källa:
XElement.cs
Källa:
XElement.cs
Källa:
XElement.cs

Viktigt!

Detta API uppfyller inte CLS.

Omvandla värdet för detta XElement till en Nullable<T> av Boolean.

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

Parametrar

element
XElement

Att XElement kasta till Nullable<T> av Boolean.

Returer

En Nullable<T> av Boolean dessa innehåller innehållet i den här XElement.

Attribut

Undantag

Elementet är inte null och innehåller inget giltigt Boolean värde.

Exempel

I följande exempel skapas ett element med booleskt innehåll. Det hämtar sedan värdet genom att gjuta till av Nullable<T>Boolean.

XElement root = new XElement("Root",
    new XElement("BoolValue1", true),
    new XElement("BoolValue2", false));
bool? bool1 = (bool?)root.Element("BoolValue1");
bool? bool2 = (bool?)root.Element("BoolValue2");
Console.WriteLine("Nullable Boolean: value1={0}", bool1);
Console.WriteLine("Nullable Boolean: value2={0}", bool2);
Dim root As XElement = _
        <Root>
            <BoolValue1>true</BoolValue1>
            <BoolValue2>false</BoolValue2>
        </Root>

Dim value1 As Nullable(Of Boolean) = CType(root.Element("BoolValue1"), Nullable(Of Boolean))
Dim value2 As Nullable(Of Boolean) = CType(root.Element("BoolValue2"), Nullable(Of Boolean))
Console.WriteLine("Nullable Boolean: value1={0}", IIf(value1.HasValue, value1.ToString(), "null"))
Console.WriteLine("Nullable Boolean: value2={0}", IIf(value2.HasValue, value2.ToString(), "null"))

Det här exemplet genererar följande utdata:

Nullable Boolean: value1=True
Nullable Boolean: value2=False

Kommentarer

När du konverterar till Nullable<T>Boolean från ett attribut eller element är tillåtna värden "0", "1" och alla strängar som ger "true" eller "false" efter trimning och konvertering till gemener.

Se även

Gäller för

Explicit(XElement to Nullable<Decimal>)

Källa:
XElement.cs
Källa:
XElement.cs
Källa:
XElement.cs
Källa:
XElement.cs
Källa:
XElement.cs

Viktigt!

Detta API uppfyller inte CLS.

Omvandla värdet för detta XElement till en Nullable<T> av Decimal.

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

Parametrar

element
XElement

Att XElement kasta till Nullable<T> av Decimal.

Returer

En Nullable<T> av Decimal dessa innehåller innehållet i den här XElement.

Attribut

Undantag

Elementet är inte null och innehåller inget giltigt Decimal värde.

Exempel

I följande exempel skapas ett element med decimalinnehåll. Det hämtar sedan värdet genom att gjuta till av Nullable<T>Decimal.

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

Det här exemplet genererar följande utdata:

Nullable decimal: value=79228162514264337593543950335

Se även

Gäller för

Explicit(XElement to Boolean)

Källa:
XElement.cs
Källa:
XElement.cs
Källa:
XElement.cs
Källa:
XElement.cs
Källa:
XElement.cs

Viktigt!

Detta API uppfyller inte CLS.

Omvandla värdet för detta XElement till en Boolean.

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

Parametrar

element
XElement

Att XElement kasta till Boolean.

Returer

En Boolean som innehåller innehållet i den här XElement.

Attribut

Undantag

Elementet innehåller inget giltigt Boolean värde.

Parametern element är null.

Exempel

I följande exempel skapas vissa element med booleska värden. Det kastar dem sedan till Boolean.

XElement root = new XElement("Root",
    new XElement("BoolValue1", true),
    new XElement("BoolValue2", false)
);
bool bool1 = (bool)root.Element("BoolValue1");
bool bool2 = (bool)root.Element("BoolValue2");
Console.WriteLine("(bool)BoolValue1={0}", bool1);
Console.WriteLine("(bool)BoolValue2={0}", bool2);
Dim root As XElement = _
        <Root>
            <BoolValue1>true</BoolValue1>
            <BoolValue2>false</BoolValue2>
        </Root>
Dim bool1 As Boolean = CBool(root.Element("BoolValue1"))
Dim bool2 As Boolean = CBool(root.Element("BoolValue2"))
Console.WriteLine("(bool)BoolValue1={0}", bool1)
Console.WriteLine("(bool)BoolValue2={0}", bool2)

Det här exemplet genererar följande utdata:

(bool)BoolValue1=True
(bool)BoolValue2=False

Kommentarer

När du konverterar till Boolean från ett attribut eller element är tillåtna värden "0", "1" och alla strängar som ger "true" eller "false" efter trimning och konvertering till gemener.

Se även

Gäller för

Explicit(XElement to DateTime)

Källa:
XElement.cs
Källa:
XElement.cs
Källa:
XElement.cs
Källa:
XElement.cs
Källa:
XElement.cs

Viktigt!

Detta API uppfyller inte CLS.

Omvandla värdet för detta XElement till en DateTime.

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

Parametrar

element
XElement

Att XElement kasta till DateTime.

Returer

En DateTime som innehåller innehållet i den här XElement.

Attribut

Undantag

Elementet innehåller inget giltigt DateTime värde.

Parametern element är null.

element är null.

Exempel

I följande exempel skapas ett element med datum- och tidsinnehåll. Sedan omvandlas den till DateTime för att hämta värdet.

// 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 DateTime(2006, 10, 6, 12, 30, 0));
Console.WriteLine(root);

// Cast from a strictly formatted XML element.
DateTime dt = (DateTime)root;
Console.WriteLine("dt={0}", dt);
Console.WriteLine("-----");

// If root is formatted in some different way:
XElement dtElement = new XElement("OrderDate", "October 6, 2006");
Console.WriteLine(dtElement);
DateTime orderDate = (DateTime)dtElement;
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><%= New DateTime(2006, 10, 6, 12, 30, 0) %></Root>
Console.WriteLine(root)

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

' If root is formatted in some different way:
Dim dtElement As XElement = <OrderDate>October 6, 2006</OrderDate>
Console.WriteLine(dtElement)
Dim orderDate As DateTime = CType(dtElement, DateTime)
Console.WriteLine("orderDate={0:d}", orderDate)

Det här exemplet genererar följande utdata:

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

Kommentarer

Värdeutrymmet för ett attribut eller element som innehåller datum- och tidsinnehåll är nära relaterat till de datum och tider som beskrivs i ISO 8601. När du skapar ett attribut eller element som innehåller datum- och tidsinnehåll formateras attribut- eller elementvärdena enligt W3C-specifikationen. Mer information finns i W3C-specifikationen.

Beteendet är släpphänt vid gjutning till ett DateTime från ett attribut eller element. Även om attributet eller elementvärdet inte formateras exakt enligt W3C-specifikationen konverteras värdet korrekt till en DateTime.

Den här konverteringsoperatorn använder CultureInfo.InvariantCulture för att konvertera från en DateTime.

Se även

Gäller för

Explicit(XElement to DateTimeOffset)

Källa:
XElement.cs
Källa:
XElement.cs
Källa:
XElement.cs
Källa:
XElement.cs
Källa:
XElement.cs

Viktigt!

Detta API uppfyller inte CLS.

Omvandla värdet för detta XAttribute till en DateTimeOffset.

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

Parametrar

element
XElement

Att XElement kasta till DateTimeOffset.

Returer

En DateTimeOffset som innehåller innehållet i den här XElement.

Attribut

Undantag

Elementet innehåller inget giltigt DateTimeOffset värde.

Parametern element är null.

element är null.

Exempel

I följande exempel skapas ett element med datum- och tidsinnehåll. Den genererar sedan till DateTimeOffset för att hämta värdet.

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

DateTimeOffset dt = (DateTimeOffset)root.Element("Child");
Console.WriteLine("dt={0}", dt);
Dim root As XElement = _
    <Root>
        <Child><%= New DateTimeOffset(New DateTime(2006, 10, 6, 12, 30, 0)) %></Child>
    </Root>
Console.WriteLine(root)

Dim dt As DateTimeOffset = CType(root.<Child>(0), DateTimeOffset)
Console.WriteLine("dt={0}", dt)

Det här exemplet genererar följande utdata:

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

Kommentarer

Den här konverteringsoperatorn XmlConvert använder klassen för att utföra konverteringen.

Se även

Gäller för

Explicit(XElement to Double)

Källa:
XElement.cs
Källa:
XElement.cs
Källa:
XElement.cs
Källa:
XElement.cs
Källa:
XElement.cs

Viktigt!

Detta API uppfyller inte CLS.

Omvandla värdet för detta XElement till en Double.

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

Parametrar

element
XElement

Att XElement kasta till Double.

Returer

En Double som innehåller innehållet i den här XElement.

Attribut

Undantag

Elementet innehåller inget giltigt Double värde.

Parametern element är null.

element är null.

Exempel

I följande exempel skapas ett attribut med double innehåll. Det hämtar sedan värdet genom att gjuta till Double.

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

Det här exemplet genererar följande utdata:

value=1.79769313486231E+308

Se även

Gäller för

Explicit(XElement to Guid)

Källa:
XElement.cs
Källa:
XElement.cs
Källa:
XElement.cs
Källa:
XElement.cs
Källa:
XElement.cs

Viktigt!

Detta API uppfyller inte CLS.

Omvandla värdet för detta XElement till en Guid.

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

Parametrar

element
XElement

Att XElement kasta till Guid.

Returer

En Guid som innehåller innehållet i den här XElement.

Attribut

Undantag

Elementet innehåller inget giltigt Guid värde.

Parametern element är null.

element är null.

Exempel

I följande exempel skapas ett element med ett guid som innehåll. Det hämtar sedan värdet genom att gjuta till Guid.

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

Det här exemplet genererar följande utdata:

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

Se även

Gäller för

Explicit(XElement to Decimal)

Källa:
XElement.cs
Källa:
XElement.cs
Källa:
XElement.cs
Källa:
XElement.cs
Källa:
XElement.cs

Viktigt!

Detta API uppfyller inte CLS.

Omvandla värdet för detta XElement till en Decimal.

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

Parametrar

element
XElement

Att XElement kasta till Decimal.

Returer

En Decimal som innehåller innehållet i den här XElement.

Attribut

Undantag

Elementet innehåller inget giltigt Decimal värde.

Parametern element är null.

element är null.

Exempel

I följande exempel skapas ett element med ett decimalvärde. Sedan hämtar den värdet för attributet genom att gjuta till Decimal.

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

Det här exemplet genererar följande utdata:

value=79228162514264337593543950335

Se även

Gäller för

Explicit(XElement to Int64)

Källa:
XElement.cs
Källa:
XElement.cs
Källa:
XElement.cs
Källa:
XElement.cs
Källa:
XElement.cs

Viktigt!

Detta API uppfyller inte CLS.

Omvandla värdet för detta XElement till en Int64.

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

Parametrar

element
XElement

Att XElement kasta till Int64.

Returer

En Int64 som innehåller innehållet i den här XElement.

Attribut

Undantag

Elementet innehåller inget giltigt Int64 värde.

Parametern element är null.

element är null.

Exempel

I följande exempel skapas ett element med ett långt heltal som innehåll. Sedan hämtar den värdet för elementet genom att gjuta till Int64.

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

Det här exemplet genererar följande utdata:

value=9223372036854775807

Se även

Gäller för

Explicit(XElement to Nullable<Double>)

Källa:
XElement.cs
Källa:
XElement.cs
Källa:
XElement.cs
Källa:
XElement.cs
Källa:
XElement.cs

Viktigt!

Detta API uppfyller inte CLS.

Omvandla värdet för detta XElement till en Nullable<T> av Double.

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

Parametrar

element
XElement

Att XElement kasta till Nullable<T> av Double.

Returer

En Nullable<T> av Double dessa innehåller innehållet i den här XElement.

Attribut

Undantag

Elementet är inte null och innehåller inget giltigt Double värde.

Exempel

I följande exempel skapas ett element med flyttal med dubbel precision. Det hämtar sedan värdet genom att gjuta till av Nullable<T>Double.

XElement root = new XElement("Root",
    new XElement("Value", 1.79769313486231e308)
);
double? value = (double?)root.Element("Value");
Console.WriteLine("Nullable double: value={0}", value == null ? "null" : value.ToString());
Dim root As XElement = _
        <Root>
            <Value>1.79769313486231e308</Value>
        </Root>

Dim value As Nullable(Of Double) = CType(root.Element("Value"), Nullable(Of Double))
Console.WriteLine("Nullable double: value={0}", IIf(value.HasValue, value.ToString(), "null"))

Det här exemplet genererar följande utdata:

Nullable double: value=1.79769313486231E+308

Se även

Gäller för

Explicit(XElement to Nullable<DateTime>)

Källa:
XElement.cs
Källa:
XElement.cs
Källa:
XElement.cs
Källa:
XElement.cs
Källa:
XElement.cs

Viktigt!

Detta API uppfyller inte CLS.

Omvandla värdet för detta XElement till en Nullable<T> av DateTime.

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

Parametrar

element
XElement

Att XElement kasta till Nullable<T> av DateTime.

Returer

En Nullable<T> av DateTime dessa innehåller innehållet i den här XElement.

Attribut

Undantag

Elementet är inte null och innehåller inget giltigt DateTime värde.

Exempel

I följande exempel skapas ett element med datum och tid som innehåll. Det hämtar sedan värdet genom att gjuta till av Nullable<T>DateTime.

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

Det här exemplet genererar följande utdata:

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

Kommentarer

Värdeutrymmet för ett attribut eller element som innehåller datum- och tidsinnehåll är nära relaterat till de datum och tider som beskrivs i ISO 8601. När du skapar ett attribut eller element som innehåller datum- och tidsinnehåll formateras attribut- eller elementvärdena enligt W3C-specifikationen. Mer information finns i W3C-specifikationen.

Beteendet är släpphänt vid gjutning till ett Nullable<T> av DateTime från ett attribut eller element. Även om attributet eller elementvärdet inte är exakt formaterat enligt W3C-specifikationen konverteras värdet korrekt till en Nullable<T> av DateTime.

Den här konverteringsoperatorn använder CultureInfo.InvariantCulture för att konvertera från en DateTime.

Se även

Gäller för

Explicit(XElement to Nullable<DateTimeOffset>)

Källa:
XElement.cs
Källa:
XElement.cs
Källa:
XElement.cs
Källa:
XElement.cs
Källa:
XElement.cs

Viktigt!

Detta API uppfyller inte CLS.

Omvandla värdet för detta XElement till en Nullable<T> av DateTimeOffset.

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

Parametrar

element
XElement

Att XElement kasta till en Nullable<T> av DateTimeOffset.

Returer

En Nullable<T> av DateTimeOffset dessa innehåller innehållet i den här XElement.

Attribut

Undantag

Elementet är inte null och innehåller inget giltigt DateTimeOffset värde.

Exempel

I följande exempel skapas ett element med datum- och tidsinnehåll. Den genererar sedan till Nullable<T>DateTimeOffset för att hämta värdet.

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

DateTimeOffset? dt = (DateTimeOffset?)root.Element("Child");
Console.WriteLine("dt={0}", dt);
Dim root As XElement = _
    <Root>
        <Child><%= New DateTimeOffset(New DateTime(2006, 10, 6, 12, 30, 0)) %></Child>
    </Root>
Console.WriteLine(root)

Dim dt As Nullable(Of DateTimeOffset) = CType(root.<Child>(0), Nullable(Of DateTimeOffset))
Console.WriteLine("dt={0}", dt)

Det här exemplet genererar följande utdata:

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

Kommentarer

Den här konverteringsoperatorn XmlConvert använder klassen för att utföra konverteringen.

Se även

Gäller för

Explicit(XElement to Int32)

Källa:
XElement.cs
Källa:
XElement.cs
Källa:
XElement.cs
Källa:
XElement.cs
Källa:
XElement.cs

Viktigt!

Detta API uppfyller inte CLS.

Omvandla värdet för detta XElement till en Int32.

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

Parametrar

element
XElement

Att XElement kasta till Int32.

Returer

En Int32 som innehåller innehållet i den här XElement.

Attribut

Undantag

Elementet innehåller inget giltigt Int32 värde.

Parametern element är null.

Exempel

I följande exempel skapas ett element med ett heltal som innehåll. Det hämtar sedan värdet genom att gjuta till Int32.

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

Det här exemplet genererar följande utdata:

value=2147483647

Se även

Gäller för