XAttribute.Explicit Operator
Definition
Wichtig
Einige Informationen beziehen sich auf Vorabversionen, die vor dem Release ggf. grundlegend überarbeitet werden. Microsoft übernimmt hinsichtlich der hier bereitgestellten Informationen keine Gewährleistungen, seien sie ausdrücklich oder konkludent.
Überlädt
Explicit(XAttribute to Nullable<Int64>)
- Quelle:
- XAttribute.cs
- Quelle:
- XAttribute.cs
- Quelle:
- XAttribute.cs
- Quelle:
- XAttribute.cs
- Quelle:
- XAttribute.cs
Wichtig
Diese API ist nicht CLS-kompatibel.
Wandeln Sie den Wert dieses XAttribute Werts in eine Nullable<T> von 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)
Parameter
- attribute
- XAttribute
Der XAttribute zum Umwandeln in eine Nullable<T> von Int64.
Gibt zurück
Eine Nullable<T> davon Int64 , die den Inhalt dieses XAttributeInhalts enthält.
- Attribute
Ausnahmen
Das Attribut enthält keinen gültigen Int64 Wert.
Beispiele
Im folgenden Beispiel wird ein Attribut mit langen ganzzahligen Inhalten erstellt. Anschließend wird der Wert durch Umwandlung in Nullable<T> .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"))
Dieses Beispiel erzeugt die folgende Ausgabe:
Nullable long: value=9223372036854775807
Weitere Informationen
Gilt für:
Explicit(XAttribute to Nullable<Single>)
- Quelle:
- XAttribute.cs
- Quelle:
- XAttribute.cs
- Quelle:
- XAttribute.cs
- Quelle:
- XAttribute.cs
- Quelle:
- XAttribute.cs
Wichtig
Diese API ist nicht CLS-kompatibel.
Wandeln Sie den Wert dieses XAttribute Werts in eine Nullable<T> von 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)
Parameter
- attribute
- XAttribute
Der XAttribute zu gegossene Nullable<T> von Single.
Gibt zurück
Eine Nullable<T> davon Single , die den Inhalt dieses XAttributeInhalts enthält.
- Attribute
Ausnahmen
Das Attribut enthält keinen gültigen Single Wert.
Beispiele
Im folgenden Beispiel wird ein Attribut mit einfachem Gleitkommainhalt erstellt. Anschließend wird der Wert durch Umwandlung in Nullable<T> .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"))
Dieses Beispiel erzeugt die folgende Ausgabe:
Nullable Single: value=3.402823E+38
Weitere Informationen
Gilt für:
Explicit(XAttribute to Nullable<TimeSpan>)
- Quelle:
- XAttribute.cs
- Quelle:
- XAttribute.cs
- Quelle:
- XAttribute.cs
- Quelle:
- XAttribute.cs
- Quelle:
- XAttribute.cs
Wichtig
Diese API ist nicht CLS-kompatibel.
Wandeln Sie den Wert dieses XAttribute Werts in eine Nullable<T> von 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)
Parameter
- attribute
- XAttribute
Der XAttribute zum Umwandeln in eine Nullable<T> von TimeSpan.
Gibt zurück
Eine Nullable<T> davon TimeSpan , die den Inhalt dieses XAttributeInhalts enthält.
- Attribute
Ausnahmen
Das Attribut enthält keinen gültigen TimeSpan Wert.
Beispiele
Im folgenden Beispiel wird ein Attribut mit Inhalt der Zeitspanne erstellt. Anschließend wird der Wert durch Umwandlung in Nullable<T> .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"))
Dieses Beispiel erzeugt die folgende Ausgabe:
Nullable TimeSpan: value=01:05:30
Hinweise
Der Wertbereich eines Attributs oder Elements, das Inhalt der Zeitspanne enthält, hängt eng mit dem Dauerinhalt zusammen, wie in ISO 8601 beschrieben. Beim Erstellen eines Attributs oder Elements, das Einen Zeitrauminhalt enthält, werden die Attribut- oder Elementwerte gemäß der W3C-Spezifikation formatiert. Weitere Details finden Sie in der W3C-Spezifikation.
Das Verhalten ist beim Umwandeln in ein Nullable<T> Von TimeSpan einem Attribut oder Element lax. Auch wenn der Attribut- oder Elementwert nicht exakt gemäß der W3C-Spezifikation formatiert ist, wird der Wert entsprechend in eins Nullable<T>TimeSpankonvertiert.
Weitere Informationen
Gilt für:
Explicit(XAttribute to Nullable<UInt32>)
- Quelle:
- XAttribute.cs
- Quelle:
- XAttribute.cs
- Quelle:
- XAttribute.cs
- Quelle:
- XAttribute.cs
- Quelle:
- XAttribute.cs
Wichtig
Diese API ist nicht CLS-kompatibel.
Wandeln Sie den Wert dieses XAttribute Werts in eine Nullable<T> von 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)
Parameter
- attribute
- XAttribute
Der XAttribute zum Umwandeln in eine Nullable<T> von UInt32.
Gibt zurück
Eine Nullable<T> davon UInt32 , die den Inhalt dieses XAttributeInhalts enthält.
- Attribute
Ausnahmen
Das Attribut enthält keinen gültigen UInt32 Wert.
Beispiele
Im folgenden Beispiel wird ein Attribut mit nicht signierten ganzzahligen Inhalten erstellt. Anschließend wird der Wert durch Umwandlung in Nullable<T> .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"))
Dieses Beispiel erzeugt die folgende Ausgabe:
Nullable uint: value=4294967295
Weitere Informationen
Gilt für:
Explicit(XAttribute to Nullable<UInt64>)
- Quelle:
- XAttribute.cs
- Quelle:
- XAttribute.cs
- Quelle:
- XAttribute.cs
- Quelle:
- XAttribute.cs
- Quelle:
- XAttribute.cs
Wichtig
Diese API ist nicht CLS-kompatibel.
Wandeln Sie den Wert dieses XAttribute Werts in eine Nullable<T> von 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)
Parameter
- attribute
- XAttribute
Der XAttribute zum Umwandeln in eine Nullable<T> von UInt64.
Gibt zurück
Eine Nullable<T> davon UInt64 , die den Inhalt dieses XAttributeInhalts enthält.
- Attribute
Ausnahmen
Das Attribut enthält keinen gültigen UInt64 Wert.
Beispiele
Im folgenden Beispiel wird ein Attribut mit nicht signierten ganzzahligen Inhalten erstellt. Anschließend wird der Wert durch Umwandlung in Nullable<T> .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"))
Dieses Beispiel erzeugt die folgende Ausgabe:
Nullable ulong: value=9223372036854775807
Weitere Informationen
Gilt für:
Explicit(XAttribute to TimeSpan)
- Quelle:
- XAttribute.cs
- Quelle:
- XAttribute.cs
- Quelle:
- XAttribute.cs
- Quelle:
- XAttribute.cs
- Quelle:
- XAttribute.cs
Wichtig
Diese API ist nicht CLS-kompatibel.
Wandeln Sie den Wert dieses XAttribute Werts in ein 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
Parameter
- attribute
- XAttribute
Der XAttribute zu umwandelnde TimeSpanIn .
Gibt zurück
A TimeSpan , das den Inhalt dieses XAttributeInhalts enthält.
- Attribute
Ausnahmen
Das Attribut enthält keinen gültigen TimeSpan Wert.
Der attribute Parameter ist null.
Beispiele
Im folgenden Beispiel wird ein Attribut mit Inhalt der Zeitspanne erstellt. Anschließend wird der Wert durch Umwandlung in 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)
Dieses Beispiel erzeugt die folgende Ausgabe:
value=01:05:30
Hinweise
Der Wertbereich eines Attributs oder Elements, das Inhalt der Zeitspanne enthält, hängt eng mit dem Dauerinhalt zusammen, wie in ISO 8601 beschrieben. Beim Erstellen eines Attributs oder Elements, das Einen Zeitrauminhalt enthält, werden die Attribut- oder Elementwerte gemäß der W3C-Spezifikation formatiert. Weitere Details finden Sie in der W3C-Spezifikation.
Verhalten ist beim Umwandeln in ein TimeSpan Attribut oder Element lax. Auch wenn der Attribut- oder Elementwert nicht exakt gemäß der W3C-Spezifikation formatiert ist, wird der Wert entsprechend in ein .TimeSpan
Weitere Informationen
Gilt für:
Explicit(XAttribute to String)
- Quelle:
- XAttribute.cs
- Quelle:
- XAttribute.cs
- Quelle:
- XAttribute.cs
- Quelle:
- XAttribute.cs
- Quelle:
- XAttribute.cs
Wichtig
Diese API ist nicht CLS-kompatibel.
Wandeln Sie den Wert dieses XAttribute Werts in ein 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
Parameter
- attribute
- XAttribute
Der XAttribute zu umwandelnde StringIn .
Gibt zurück
A String , das den Inhalt dieses XAttributeInhalts enthält.
- Attribute
Beispiele
Im folgenden Beispiel wird ein Attribut mit Zeichenfolgeninhalt erstellt. Anschließend wird der Wert durch Umwandlung in 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)
Dieses Beispiel erzeugt die folgende Ausgabe:
(string)att=attribute content
Weitere Informationen
Gilt für:
Explicit(XAttribute to Nullable<Int32>)
- Quelle:
- XAttribute.cs
- Quelle:
- XAttribute.cs
- Quelle:
- XAttribute.cs
- Quelle:
- XAttribute.cs
- Quelle:
- XAttribute.cs
Wichtig
Diese API ist nicht CLS-kompatibel.
Wandeln Sie den Wert dieses XAttribute Werts in eine Nullable<T> von 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)
Parameter
- attribute
- XAttribute
Der XAttribute zum Umwandeln in eine Nullable<T> von Int32.
Gibt zurück
Eine Nullable<T> davon Int32 , die den Inhalt dieses XAttributeInhalts enthält.
- Attribute
Beispiele
Im folgenden Beispiel wird ein Attribut mit ganzzahligem Inhalt erstellt. Anschließend wird der Wert durch Umwandlung in Nullable<T> .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"))
Dieses Beispiel erzeugt die folgende Ausgabe:
Nullable int: value=2147483647
Weitere Informationen
Gilt für:
Explicit(XAttribute to UInt32)
- Quelle:
- XAttribute.cs
- Quelle:
- XAttribute.cs
- Quelle:
- XAttribute.cs
- Quelle:
- XAttribute.cs
- Quelle:
- XAttribute.cs
Wichtig
Diese API ist nicht CLS-kompatibel.
Wandeln Sie den Wert dieses XAttribute Werts in ein 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
Parameter
- attribute
- XAttribute
Der XAttribute zu umwandelnde UInt32In .
Gibt zurück
A UInt32 , das den Inhalt dieses XAttributeInhalts enthält.
- Attribute
Ausnahmen
Das Attribut enthält keinen gültigen UInt32 Wert.
Der attribute Parameter ist null.
Beispiele
Im folgenden Beispiel wird ein Attribut mit nicht signierten ganzzahligen Inhalten erstellt. Anschließend wird der Wert durch Umwandlung in 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)
Dieses Beispiel erzeugt die folgende Ausgabe:
value=4294967295
Weitere Informationen
Gilt für:
Explicit(XAttribute to UInt64)
- Quelle:
- XAttribute.cs
- Quelle:
- XAttribute.cs
- Quelle:
- XAttribute.cs
- Quelle:
- XAttribute.cs
- Quelle:
- XAttribute.cs
Wichtig
Diese API ist nicht CLS-kompatibel.
Wandeln Sie den Wert dieses XAttribute Werts in ein 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
Parameter
- attribute
- XAttribute
Der XAttribute zu umwandelnde UInt64In .
Gibt zurück
A UInt64 , das den Inhalt dieses XAttributeInhalts enthält.
- Attribute
Ausnahmen
Das Attribut enthält keinen gültigen UInt64 Wert.
Der attribute Parameter ist null.
Beispiele
Im folgenden Beispiel wird ein Attribut mit nicht signierten ganzzahligen Inhalten erstellt. Anschließend wird der Wert durch Umwandlung in 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)
Dieses Beispiel erzeugt die folgende Ausgabe:
value=1844674407370955161
Weitere Informationen
Gilt für:
Explicit(XAttribute to Single)
- Quelle:
- XAttribute.cs
- Quelle:
- XAttribute.cs
- Quelle:
- XAttribute.cs
- Quelle:
- XAttribute.cs
- Quelle:
- XAttribute.cs
Wichtig
Diese API ist nicht CLS-kompatibel.
Wandeln Sie den Wert dieses XAttribute Werts in ein 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
Parameter
- attribute
- XAttribute
Der XAttribute zu umwandelnde SingleIn .
Gibt zurück
A Single , das den Inhalt dieses XAttributeInhalts enthält.
- Attribute
Ausnahmen
Das Attribut enthält keinen gültigen Single Wert.
Der attribute Parameter ist null.
Beispiele
Im folgenden Beispiel wird ein Attribut mit einfachem Gleitkommainhalt erstellt. Anschließend wird der Wert durch Umwandlung in 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)
Dieses Beispiel erzeugt die folgende Ausgabe:
value=3.402823E+38
Weitere Informationen
Gilt für:
Explicit(XAttribute to Nullable<Guid>)
- Quelle:
- XAttribute.cs
- Quelle:
- XAttribute.cs
- Quelle:
- XAttribute.cs
- Quelle:
- XAttribute.cs
- Quelle:
- XAttribute.cs
Wichtig
Diese API ist nicht CLS-kompatibel.
Wandeln Sie den Wert dieses XAttribute Werts in eine Nullable<T> von 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)
Parameter
- attribute
- XAttribute
Der XAttribute zum Umwandeln in eine Nullable<T> von Guid.
Gibt zurück
Eine Nullable<T> davon Guid , die den Inhalt dieses XAttributeInhalts enthält.
- Attribute
Ausnahmen
Das Attribut enthält keinen gültigen Guid Wert.
Beispiele
Im folgenden Beispiel wird ein Attribut mit GUID-Inhalt erstellt. Anschließend wird der Wert durch Umwandlung in Nullable<T> .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"))
Dieses Beispiel erzeugt die folgende Ausgabe:
Nullable Guid: value=3c1cc55b-baff-4b7a-9d17-077af3aa5730
Weitere Informationen
Gilt für:
Explicit(XAttribute to Nullable<Decimal>)
- Quelle:
- XAttribute.cs
- Quelle:
- XAttribute.cs
- Quelle:
- XAttribute.cs
- Quelle:
- XAttribute.cs
- Quelle:
- XAttribute.cs
Wichtig
Diese API ist nicht CLS-kompatibel.
Wandeln Sie den Wert dieses XAttribute Werts in eine Nullable<T> von 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)
Parameter
- attribute
- XAttribute
Der XAttribute zu gegossene Nullable<T> von Decimal.
Gibt zurück
Eine Nullable<T> davon Decimal , die den Inhalt dieses XAttributeInhalts enthält.
- Attribute
Ausnahmen
Das Attribut enthält keinen gültigen Decimal Wert.
Beispiele
Im folgenden Beispiel wird ein Attribut mit Dezimalinhalt erstellt. Anschließend wird der Wert durch Umwandlung in Nullable<T> .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"))
Dieses Beispiel erzeugt die folgende Ausgabe:
Nullable decimal: value=79228162514264337593543950335
Weitere Informationen
Gilt für:
Explicit(XAttribute to Decimal)
- Quelle:
- XAttribute.cs
- Quelle:
- XAttribute.cs
- Quelle:
- XAttribute.cs
- Quelle:
- XAttribute.cs
- Quelle:
- XAttribute.cs
Wichtig
Diese API ist nicht CLS-kompatibel.
Wandeln Sie den Wert dieses XAttribute Werts in ein 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
Parameter
- attribute
- XAttribute
Der XAttribute zu umwandelnde DecimalIn .
Gibt zurück
A Decimal , das den Inhalt dieses XAttributeInhalts enthält.
- Attribute
Ausnahmen
Das Attribut enthält keinen gültigen Decimal Wert.
Der attribute Parameter ist null.
Beispiele
Im folgenden Beispiel wird ein Attribut mit einem Dezimalwert erstellt. Anschließend wird der Wert des Attributs durch Umwandlung in 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)
Dieses Beispiel erzeugt die folgende Ausgabe:
value=79228162514264337593543950335
Weitere Informationen
Gilt für:
Explicit(XAttribute to Nullable<DateTimeOffset>)
- Quelle:
- XAttribute.cs
- Quelle:
- XAttribute.cs
- Quelle:
- XAttribute.cs
- Quelle:
- XAttribute.cs
- Quelle:
- XAttribute.cs
Wichtig
Diese API ist nicht CLS-kompatibel.
Wandeln Sie den Wert dieses XAttribute Werts in eine Nullable<T> von 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)
Parameter
- attribute
- XAttribute
Der XAttribute zum Umwandeln in eine Nullable<T> von DateTimeOffset.
Gibt zurück
Eine Nullable<T> davon DateTimeOffset , die den Inhalt dieses XAttributeInhalts enthält.
- Attribute
Ausnahmen
Das Attribut enthält keinen gültigen DateTimeOffset Wert.
Beispiele
Im folgenden Beispiel wird ein Attribut mit Datum und Uhrzeit als Inhalt erstellt. Anschließend wird der Wert durch Umwandlung in Nullable<T> .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"))
Dieses Beispiel erzeugt die folgende Ausgabe:
Nullable DateTimeOffset: value=10/6/2006 12:30:00 PM -07:00
Hinweise
Dieser Konvertierungsoperator verwendet die XmlConvert Klasse, um die Konvertierung durchzuführen.
Gilt für:
Explicit(XAttribute to Nullable<DateTime>)
- Quelle:
- XAttribute.cs
- Quelle:
- XAttribute.cs
- Quelle:
- XAttribute.cs
- Quelle:
- XAttribute.cs
- Quelle:
- XAttribute.cs
Wichtig
Diese API ist nicht CLS-kompatibel.
Wandeln Sie den Wert dieses XAttribute Werts in eine Nullable<T> von 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)
Parameter
- attribute
- XAttribute
Der XAttribute zum Umwandeln in eine Nullable<T> von DateTime.
Gibt zurück
Eine Nullable<T> davon DateTime , die den Inhalt dieses XAttributeInhalts enthält.
- Attribute
Ausnahmen
Das Attribut enthält keinen gültigen DateTime Wert.
Beispiele
Im folgenden Beispiel wird ein Attribut mit Datum und Uhrzeit als Inhalt erstellt. Anschließend wird der Wert durch Umwandlung in Nullable<T> .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"))
Dieses Beispiel erzeugt die folgende Ausgabe:
Nullable DateTime: value=10/6/2006 12:30:00 PM
Hinweise
Der Wertbereich eines Attributs oder Elements, das Datums- und Uhrzeitinhalte enthält, hängt eng mit den Datums- und Uhrzeitangaben zusammen, die in ISO 8601 beschrieben werden. Beim Erstellen eines Attributs oder Elements, das Datums- und Uhrzeitinhalte enthält, werden die Attribut- oder Elementwerte gemäß der W3C-Spezifikation formatiert. Weitere Details finden Sie in der W3C-Spezifikation.
Das Verhalten ist beim Umwandeln in ein Nullable<T> Von DateTime einem Attribut oder Element lax. Auch wenn der Attribut- oder Elementwert nicht exakt gemäß der W3C-Spezifikation formatiert ist, wird der Wert entsprechend in eins Nullable<T>DateTimekonvertiert.
Dieser Konvertierungsoperator verwendet CultureInfo.InvariantCulture zum Konvertieren aus einem DateTime.
Weitere Informationen
Gilt für:
Explicit(XAttribute to Nullable<Boolean>)
- Quelle:
- XAttribute.cs
- Quelle:
- XAttribute.cs
- Quelle:
- XAttribute.cs
- Quelle:
- XAttribute.cs
- Quelle:
- XAttribute.cs
Wichtig
Diese API ist nicht CLS-kompatibel.
Wandeln Sie den Wert dieses XAttribute Werts in eine Nullable<T> von 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)
Parameter
- attribute
- XAttribute
Der XAttribute zu gegossene Nullable<T> von Boolean.
Gibt zurück
Eine Nullable<T> davon Boolean , die den Inhalt dieses XAttributeInhalts enthält.
- Attribute
Ausnahmen
Das Attribut enthält keinen gültigen Boolean Wert.
Beispiele
Im folgenden Beispiel wird ein Attribut mit booleschen Inhalten erstellt. Anschließend wird der Wert durch Umwandlung in Nullable<T> .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)
Dieses Beispiel erzeugt die folgende Ausgabe:
Nullable boolean: BoolValue1=True
Nullable boolean: BoolValue2=False
Hinweise
Bei der Konvertierung Boolean aus einem Attribut oder Element sind zulässige Werte "0", "1" und eine beliebige Zeichenfolge, die nach dem Kürzen und Konvertieren in Kleinbuchstaben "true" oder "false" erzeugt.
Weitere Informationen
Gilt für:
Explicit(XAttribute to Int64)
- Quelle:
- XAttribute.cs
- Quelle:
- XAttribute.cs
- Quelle:
- XAttribute.cs
- Quelle:
- XAttribute.cs
- Quelle:
- XAttribute.cs
Wichtig
Diese API ist nicht CLS-kompatibel.
Wandeln Sie den Wert dieses XAttribute Werts in ein 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
Parameter
- attribute
- XAttribute
Der XAttribute zu umwandelnde Int64In .
Gibt zurück
A Int64 , das den Inhalt dieses XAttributeInhalts enthält.
- Attribute
Ausnahmen
Das Attribut enthält keinen gültigen Int64 Wert.
Der attribute Parameter ist null.
Beispiele
Im folgenden Beispiel wird ein Attribut mit einer langen ganzzahligen Zahl als Inhalt erstellt. Anschließend wird der Wert des Attributs durch Umwandlung in 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)
Dieses Beispiel erzeugt die folgende Ausgabe:
value=9223372036854775807
Weitere Informationen
Gilt für:
Explicit(XAttribute to Int32)
- Quelle:
- XAttribute.cs
- Quelle:
- XAttribute.cs
- Quelle:
- XAttribute.cs
- Quelle:
- XAttribute.cs
- Quelle:
- XAttribute.cs
Wichtig
Diese API ist nicht CLS-kompatibel.
Wandeln Sie den Wert dieses XAttribute Werts in ein 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
Parameter
- attribute
- XAttribute
Der XAttribute zu umwandelnde Int32In .
Gibt zurück
A Int32 , das den Inhalt dieses XAttributeInhalts enthält.
- Attribute
Ausnahmen
Das Attribut enthält keinen gültigen Int32 Wert.
Der attribute Parameter ist null.
Beispiele
Im folgenden Beispiel wird ein Attribut mit einer ganzen Zahl als Inhalt erstellt. Anschließend wird der Wert durch Umwandlung in 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)
Dieses Beispiel erzeugt die folgende Ausgabe:
value=2147483647
Weitere Informationen
Gilt für:
Explicit(XAttribute to Guid)
- Quelle:
- XAttribute.cs
- Quelle:
- XAttribute.cs
- Quelle:
- XAttribute.cs
- Quelle:
- XAttribute.cs
- Quelle:
- XAttribute.cs
Wichtig
Diese API ist nicht CLS-kompatibel.
Wandeln Sie den Wert dieses XAttribute Werts in ein 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
Parameter
- attribute
- XAttribute
Der XAttribute zu umwandelnde GuidIn .
Gibt zurück
A Guid , das den Inhalt dieses XAttributeInhalts enthält.
- Attribute
Ausnahmen
Das Attribut enthält keinen gültigen Guid Wert.
Der attribute Parameter ist null.
Beispiele
Im folgenden Beispiel wird ein Attribut mit einer GUID als Inhalt erstellt. Anschließend wird der Wert durch Umwandlung in 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)
Dieses Beispiel erzeugt die folgende Ausgabe:
value=3c1cc55b-baff-4b7a-9d17-077af3aa5730
Weitere Informationen
Gilt für:
Explicit(XAttribute to Double)
- Quelle:
- XAttribute.cs
- Quelle:
- XAttribute.cs
- Quelle:
- XAttribute.cs
- Quelle:
- XAttribute.cs
- Quelle:
- XAttribute.cs
Wichtig
Diese API ist nicht CLS-kompatibel.
Wandeln Sie den Wert dieses XAttribute Werts in ein 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
Parameter
- attribute
- XAttribute
Der XAttribute zu umwandelnde DoubleIn .
Gibt zurück
A Double , das den Inhalt dieses XAttributeInhalts enthält.
- Attribute
Ausnahmen
Das Attribut enthält keinen gültigen Double Wert.
Der attribute Parameter ist null.
Beispiele
Im folgenden Beispiel wird ein Attribut mit Double Inhalt erstellt. Anschließend wird der Wert durch Umwandlung in 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)
Dieses Beispiel erzeugt die folgende Ausgabe:
value=1.79769313486231E+308
Weitere Informationen
Gilt für:
Explicit(XAttribute to Nullable<Double>)
- Quelle:
- XAttribute.cs
- Quelle:
- XAttribute.cs
- Quelle:
- XAttribute.cs
- Quelle:
- XAttribute.cs
- Quelle:
- XAttribute.cs
Wichtig
Diese API ist nicht CLS-kompatibel.
Wandeln Sie den Wert dieses XAttribute Werts in eine Nullable<T> von 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)
Parameter
- attribute
- XAttribute
Der XAttribute zu gegossene Nullable<T> von Double.
Gibt zurück
Eine Nullable<T> davon Double , die den Inhalt dieses XAttributeInhalts enthält.
- Attribute
Ausnahmen
Das Attribut enthält keinen gültigen Double Wert.
Beispiele
Im folgenden Beispiel wird ein Attribut mit Gleitkommainhalt mit doppelter Genauigkeit erstellt. Anschließend wird der Wert durch Umwandlung in Nullable<T> .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"))
Dieses Beispiel erzeugt die folgende Ausgabe:
Nullable double: value=1.79769313486231E+308
Weitere Informationen
Gilt für:
Explicit(XAttribute to DateTimeOffset)
- Quelle:
- XAttribute.cs
- Quelle:
- XAttribute.cs
- Quelle:
- XAttribute.cs
- Quelle:
- XAttribute.cs
- Quelle:
- XAttribute.cs
Wichtig
Diese API ist nicht CLS-kompatibel.
Wandeln Sie den Wert dieses XAttribute Werts in ein 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
Parameter
- attribute
- XAttribute
Der XAttribute zu umwandelnde DateTimeOffsetIn .
Gibt zurück
A DateTimeOffset , das den Inhalt dieses XAttributeInhalts enthält.
- Attribute
Ausnahmen
Das Attribut enthält keinen gültigen DateTimeOffset Wert.
Der attribute Parameter ist null.
Beispiele
Im folgenden Beispiel wird ein Attribut mit Datums- und Uhrzeitinhalt erstellt. Anschließend wandelt sie in DateTimeOffset den Wert um.
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)
Dieses Beispiel erzeugt die folgende Ausgabe:
<Root Att="2006-10-06T12:30:00-07:00" />
dt=10/6/2006 12:30:00 PM -07:00
Hinweise
Dieser Konvertierungsoperator verwendet die XmlConvert Klasse, um die Konvertierung durchzuführen.
Weitere Informationen
Gilt für:
Explicit(XAttribute to DateTime)
- Quelle:
- XAttribute.cs
- Quelle:
- XAttribute.cs
- Quelle:
- XAttribute.cs
- Quelle:
- XAttribute.cs
- Quelle:
- XAttribute.cs
Wichtig
Diese API ist nicht CLS-kompatibel.
Wandeln Sie den Wert dieses XAttribute Werts in ein 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
Parameter
- attribute
- XAttribute
Der XAttribute zu umwandelnde DateTimeIn .
Gibt zurück
A DateTime , das den Inhalt dieses XAttributeInhalts enthält.
- Attribute
Ausnahmen
Das Attribut enthält keinen gültigen DateTime Wert.
Der attribute Parameter ist null.
Beispiele
Im folgenden Beispiel wird ein Attribut mit Datums- und Uhrzeitinhalt erstellt. Anschließend wandelt sie in DateTime den Wert um.
// 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)
Dieses Beispiel erzeugt die folgende Ausgabe:
<Root Att="2006-10-06T12:30:00" />
dt=10/6/2006 12:30:00 PM
-----
OrderDate="October 6, 2006"
OrderDate=10/6/2006
Hinweise
Der Wertbereich eines Attributs oder Elements, das Datums- und Uhrzeitinhalte enthält, hängt eng mit den Datums- und Uhrzeitangaben zusammen, die in ISO 8601 beschrieben werden. Beim Erstellen eines Attributs oder Elements, das Datums- und Uhrzeitinhalte enthält, werden die Attribut- oder Elementwerte gemäß der W3C-Spezifikation formatiert. Weitere Details finden Sie in der W3C-Spezifikation.
Verhalten ist beim Umwandeln in ein DateTime Attribut oder Element lax. Auch wenn der Attribut- oder Elementwert nicht exakt gemäß der W3C-Spezifikation formatiert ist, wird der Wert entsprechend in ein .DateTime
Dieser Konvertierungsoperator verwendet CultureInfo.InvariantCulture zum Konvertieren aus einem DateTime.
Weitere Informationen
Gilt für:
Explicit(XAttribute to Boolean)
- Quelle:
- XAttribute.cs
- Quelle:
- XAttribute.cs
- Quelle:
- XAttribute.cs
- Quelle:
- XAttribute.cs
- Quelle:
- XAttribute.cs
Wichtig
Diese API ist nicht CLS-kompatibel.
Wandeln Sie den Wert dieses XAttribute Werts in ein 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
Parameter
- attribute
- XAttribute
Der XAttribute zu umwandelnde BooleanIn .
Gibt zurück
A Boolean , das den Inhalt dieses XAttributeInhalts enthält.
- Attribute
Ausnahmen
Das Attribut enthält keinen gültigen Boolean Wert.
Der attribute Parameter ist null.
Beispiele
Im folgenden Beispiel wird ein Attribut mit einem Boolean Wert erstellt und anschließend in 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)
Dieses Beispiel erzeugt die folgende Ausgabe:
(bool)BoolValue=True
Hinweise
Bei der Konvertierung Boolean aus einem Attribut oder Element sind zulässige Werte "0", "1" und eine beliebige Zeichenfolge, die nach dem Kürzen und Konvertieren in Kleinbuchstaben "true" oder "false" erzeugt.