XAttribute.Explicit Operator
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
オーバーロード
Explicit(XAttribute to Nullable<Int64>)
- ソース:
- XAttribute.cs
- ソース:
- XAttribute.cs
- ソース:
- XAttribute.cs
- ソース:
- XAttribute.cs
- ソース:
- XAttribute.cs
重要
この API は CLS 準拠ではありません。
このXAttributeの値をNullable<T>の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)
パラメーター
- attribute
- XAttribute
XAttributeのNullable<T>にキャストするInt64。
返品
このNullable<T>の内容を含むInt64のXAttribute。
- 属性
例外
属性に有効な Int64 値が含まれていません。
例
次の例では、長整数コンテンツを含む属性を作成します。 その後、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"))
この例を実行すると、次の出力が生成されます。
Nullable long: value=9223372036854775807
こちらもご覧ください
適用対象
Explicit(XAttribute to Nullable<Single>)
- ソース:
- XAttribute.cs
- ソース:
- XAttribute.cs
- ソース:
- XAttribute.cs
- ソース:
- XAttribute.cs
- ソース:
- XAttribute.cs
重要
この API は CLS 準拠ではありません。
このXAttributeの値をNullable<T>の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)
パラメーター
- attribute
- XAttribute
XAttributeのNullable<T>にキャストするSingle。
返品
このNullable<T>の内容を含むSingleのXAttribute。
- 属性
例外
属性に有効な Single 値が含まれていません。
例
次の例では、単精度浮動小数点コンテンツを持つ属性を作成します。 その後、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"))
この例を実行すると、次の出力が生成されます。
Nullable Single: value=3.402823E+38
こちらもご覧ください
適用対象
Explicit(XAttribute to Nullable<TimeSpan>)
- ソース:
- XAttribute.cs
- ソース:
- XAttribute.cs
- ソース:
- XAttribute.cs
- ソース:
- XAttribute.cs
- ソース:
- XAttribute.cs
重要
この API は CLS 準拠ではありません。
このXAttributeの値をNullable<T>の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)
パラメーター
- attribute
- XAttribute
XAttributeのNullable<T>にキャストするTimeSpan。
返品
このNullable<T>の内容を含むTimeSpanのXAttribute。
- 属性
例外
属性に有効な TimeSpan 値が含まれていません。
例
次の例では、期間コンテンツを含む属性を作成します。 その後、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"))
この例を実行すると、次の出力が生成されます。
Nullable TimeSpan: value=01:05:30
注釈
タイム スパン コンテンツを含む属性または要素の値空間は、ISO 8601 で説明されているように、期間コンテンツと密接に関連しています。 タイム スパン コンテンツを含む属性または要素を作成する場合、属性または要素の値は W3C 仕様に従って書式設定されます。 詳細については、W3C 仕様を参照してください。
属性または要素からNullable<T>のTimeSpanにキャストする場合の動作は緩いです。 属性または要素の値が W3C 仕様に従って正確に書式設定されていない場合でも、値はNullable<T>のTimeSpanに適切に変換されます。
こちらもご覧ください
適用対象
Explicit(XAttribute to Nullable<UInt32>)
- ソース:
- XAttribute.cs
- ソース:
- XAttribute.cs
- ソース:
- XAttribute.cs
- ソース:
- XAttribute.cs
- ソース:
- XAttribute.cs
重要
この API は CLS 準拠ではありません。
このXAttributeの値をNullable<T>の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)
パラメーター
- attribute
- XAttribute
XAttributeのNullable<T>にキャストするUInt32。
返品
このNullable<T>の内容を含むUInt32のXAttribute。
- 属性
例外
属性に有効な UInt32 値が含まれていません。
例
次の例では、符号なし整数コンテンツを含む属性を作成します。 その後、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"))
この例を実行すると、次の出力が生成されます。
Nullable uint: value=4294967295
こちらもご覧ください
適用対象
Explicit(XAttribute to Nullable<UInt64>)
- ソース:
- XAttribute.cs
- ソース:
- XAttribute.cs
- ソース:
- XAttribute.cs
- ソース:
- XAttribute.cs
- ソース:
- XAttribute.cs
重要
この API は CLS 準拠ではありません。
このXAttributeの値をNullable<T>の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)
パラメーター
- attribute
- XAttribute
XAttributeのNullable<T>にキャストするUInt64。
返品
このNullable<T>の内容を含むUInt64のXAttribute。
- 属性
例外
属性に有効な UInt64 値が含まれていません。
例
次の例では、符号なし長整数コンテンツを持つ属性を作成します。 その後、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"))
この例を実行すると、次の出力が生成されます。
Nullable ulong: value=9223372036854775807
こちらもご覧ください
適用対象
Explicit(XAttribute to TimeSpan)
- ソース:
- XAttribute.cs
- ソース:
- XAttribute.cs
- ソース:
- XAttribute.cs
- ソース:
- XAttribute.cs
- ソース:
- XAttribute.cs
重要
この API は CLS 準拠ではありません。
この XAttribute の値を 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
パラメーター
- attribute
- XAttribute
XAttributeにキャストするTimeSpan。
返品
このTimeSpanの内容を含むXAttribute。
- 属性
例外
属性に有効な TimeSpan 値が含まれていません。
attribute パラメーターはnull。
例
次の例では、期間コンテンツを含む属性を作成します。 その後、 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)
この例を実行すると、次の出力が生成されます。
value=01:05:30
注釈
タイム スパン コンテンツを含む属性または要素の値空間は、ISO 8601 で説明されているように、期間コンテンツと密接に関連しています。 タイム スパン コンテンツを含む属性または要素を作成する場合、属性または要素の値は W3C 仕様に従って書式設定されます。 詳細については、W3C 仕様を参照してください。
属性または要素から TimeSpan にキャストする場合の動作は緩いです。 属性または要素の値が W3C 仕様に従って正確に書式設定されていない場合でも、値は適切に TimeSpanに変換されます。
こちらもご覧ください
適用対象
Explicit(XAttribute to String)
- ソース:
- XAttribute.cs
- ソース:
- XAttribute.cs
- ソース:
- XAttribute.cs
- ソース:
- XAttribute.cs
- ソース:
- XAttribute.cs
重要
この API は CLS 準拠ではありません。
この XAttribute の値を 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
パラメーター
- attribute
- XAttribute
XAttributeにキャストするString。
返品
このStringの内容を含むXAttribute。
- 属性
例
次の例では、文字列コンテンツを含む属性を作成します。 その後、 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)
この例を実行すると、次の出力が生成されます。
(string)att=attribute content
こちらもご覧ください
適用対象
Explicit(XAttribute to Nullable<Int32>)
- ソース:
- XAttribute.cs
- ソース:
- XAttribute.cs
- ソース:
- XAttribute.cs
- ソース:
- XAttribute.cs
- ソース:
- XAttribute.cs
重要
この API は CLS 準拠ではありません。
このXAttributeの値をNullable<T>の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)
パラメーター
- attribute
- XAttribute
XAttributeのNullable<T>にキャストするInt32。
返品
このNullable<T>の内容を含むInt32のXAttribute。
- 属性
例
次の例では、整数コンテンツを含む属性を作成します。 その後、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"))
この例を実行すると、次の出力が生成されます。
Nullable int: value=2147483647
こちらもご覧ください
適用対象
Explicit(XAttribute to UInt32)
- ソース:
- XAttribute.cs
- ソース:
- XAttribute.cs
- ソース:
- XAttribute.cs
- ソース:
- XAttribute.cs
- ソース:
- XAttribute.cs
重要
この API は CLS 準拠ではありません。
この XAttribute の値を 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
パラメーター
- attribute
- XAttribute
XAttributeにキャストするUInt32。
返品
このUInt32の内容を含むXAttribute。
- 属性
例外
属性に有効な UInt32 値が含まれていません。
attribute パラメーターはnull。
例
次の例では、符号なし整数コンテンツを含む属性を作成します。 その後、 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)
この例を実行すると、次の出力が生成されます。
value=4294967295
こちらもご覧ください
適用対象
Explicit(XAttribute to UInt64)
- ソース:
- XAttribute.cs
- ソース:
- XAttribute.cs
- ソース:
- XAttribute.cs
- ソース:
- XAttribute.cs
- ソース:
- XAttribute.cs
重要
この API は CLS 準拠ではありません。
この XAttribute の値を 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
パラメーター
- attribute
- XAttribute
XAttributeにキャストするUInt64。
返品
このUInt64の内容を含むXAttribute。
- 属性
例外
属性に有効な UInt64 値が含まれていません。
attribute パラメーターはnull。
例
次の例では、符号なし長整数コンテンツを持つ属性を作成します。 その後、 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)
この例を実行すると、次の出力が生成されます。
value=1844674407370955161
こちらもご覧ください
適用対象
Explicit(XAttribute to Single)
- ソース:
- XAttribute.cs
- ソース:
- XAttribute.cs
- ソース:
- XAttribute.cs
- ソース:
- XAttribute.cs
- ソース:
- XAttribute.cs
重要
この API は CLS 準拠ではありません。
この XAttribute の値を 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
パラメーター
- attribute
- XAttribute
XAttributeにキャストするSingle。
返品
このSingleの内容を含むXAttribute。
- 属性
例外
属性に有効な Single 値が含まれていません。
attribute パラメーターはnull。
例
次の例では、単精度浮動小数点コンテンツを持つ属性を作成します。 その後、 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)
この例を実行すると、次の出力が生成されます。
value=3.402823E+38
こちらもご覧ください
適用対象
Explicit(XAttribute to Nullable<Guid>)
- ソース:
- XAttribute.cs
- ソース:
- XAttribute.cs
- ソース:
- XAttribute.cs
- ソース:
- XAttribute.cs
- ソース:
- XAttribute.cs
重要
この API は CLS 準拠ではありません。
このXAttributeの値をNullable<T>の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)
パラメーター
- attribute
- XAttribute
XAttributeのNullable<T>にキャストするGuid。
返品
このNullable<T>の内容を含むGuidのXAttribute。
- 属性
例外
属性に有効な Guid 値が含まれていません。
例
次の例では、guid コンテンツを含む属性を作成します。 その後、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"))
この例を実行すると、次の出力が生成されます。
Nullable Guid: value=3c1cc55b-baff-4b7a-9d17-077af3aa5730
こちらもご覧ください
適用対象
Explicit(XAttribute to Nullable<Decimal>)
- ソース:
- XAttribute.cs
- ソース:
- XAttribute.cs
- ソース:
- XAttribute.cs
- ソース:
- XAttribute.cs
- ソース:
- XAttribute.cs
重要
この API は CLS 準拠ではありません。
このXAttributeの値をNullable<T>の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)
パラメーター
- attribute
- XAttribute
XAttributeのNullable<T>にキャストするDecimal。
返品
このNullable<T>の内容を含むDecimalのXAttribute。
- 属性
例外
属性に有効な Decimal 値が含まれていません。
例
次の例では、10 進コンテンツを含む属性を作成します。 その後、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"))
この例を実行すると、次の出力が生成されます。
Nullable decimal: value=79228162514264337593543950335
こちらもご覧ください
適用対象
Explicit(XAttribute to Decimal)
- ソース:
- XAttribute.cs
- ソース:
- XAttribute.cs
- ソース:
- XAttribute.cs
- ソース:
- XAttribute.cs
- ソース:
- XAttribute.cs
重要
この API は CLS 準拠ではありません。
この XAttribute の値を 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
パラメーター
- attribute
- XAttribute
XAttributeにキャストするDecimal。
返品
このDecimalの内容を含むXAttribute。
- 属性
例外
属性に有効な Decimal 値が含まれていません。
attribute パラメーターはnull。
例
次の例では、10 進値を持つ属性を作成します。 次に、 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)
この例を実行すると、次の出力が生成されます。
value=79228162514264337593543950335
こちらもご覧ください
適用対象
Explicit(XAttribute to Nullable<DateTimeOffset>)
- ソース:
- XAttribute.cs
- ソース:
- XAttribute.cs
- ソース:
- XAttribute.cs
- ソース:
- XAttribute.cs
- ソース:
- XAttribute.cs
重要
この API は CLS 準拠ではありません。
このXAttributeの値をNullable<T>の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)
パラメーター
- attribute
- XAttribute
XAttributeのNullable<T>にキャストするDateTimeOffset。
返品
このNullable<T>の内容を含むDateTimeOffsetのXAttribute。
- 属性
例外
属性に有効な DateTimeOffset 値が含まれていません。
例
次の例では、日付と時刻をコンテンツとして持つ属性を作成します。 その後、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"))
この例を実行すると、次の出力が生成されます。
Nullable DateTimeOffset: value=10/6/2006 12:30:00 PM -07:00
注釈
この変換演算子は、 XmlConvert クラスを使用して変換を行います。
適用対象
Explicit(XAttribute to Nullable<DateTime>)
- ソース:
- XAttribute.cs
- ソース:
- XAttribute.cs
- ソース:
- XAttribute.cs
- ソース:
- XAttribute.cs
- ソース:
- XAttribute.cs
重要
この API は CLS 準拠ではありません。
このXAttributeの値をNullable<T>の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)
パラメーター
- attribute
- XAttribute
XAttributeのNullable<T>にキャストするDateTime。
返品
このNullable<T>の内容を含むDateTimeのXAttribute。
- 属性
例外
属性に有効な DateTime 値が含まれていません。
例
次の例では、日付と時刻をコンテンツとして持つ属性を作成します。 その後、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"))
この例を実行すると、次の出力が生成されます。
Nullable DateTime: value=10/6/2006 12:30:00 PM
注釈
日付と時刻の内容を含む属性または要素の値空間は、ISO 8601 で説明されている日付と時刻に密接に関連しています。 日付と時刻の内容を含む属性または要素を作成する場合、属性または要素の値は W3C 仕様に従って書式設定されます。 詳細については、W3C 仕様を参照してください。
属性または要素からNullable<T>のDateTimeにキャストする場合の動作は緩いです。 属性または要素の値が W3C 仕様に従って正確に書式設定されていない場合でも、値はNullable<T>のDateTimeに適切に変換されます。
この変換演算子は、 CultureInfo.InvariantCulture を使用して DateTimeから変換します。
こちらもご覧ください
適用対象
Explicit(XAttribute to Nullable<Boolean>)
- ソース:
- XAttribute.cs
- ソース:
- XAttribute.cs
- ソース:
- XAttribute.cs
- ソース:
- XAttribute.cs
- ソース:
- XAttribute.cs
重要
この API は CLS 準拠ではありません。
このXAttributeの値をNullable<T>の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)
パラメーター
- attribute
- XAttribute
XAttributeのNullable<T>にキャストするBoolean。
返品
このNullable<T>の内容を含むBooleanのXAttribute。
- 属性
例外
属性に有効な Boolean 値が含まれていません。
例
次の例では、ブール型のコンテンツを含む属性を作成します。 その後、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)
この例を実行すると、次の出力が生成されます。
Nullable boolean: BoolValue1=True
Nullable boolean: BoolValue2=False
注釈
属性または要素から Boolean に変換する場合、使用できる値は "0"、"1"、およびトリミング後に "true" または "false" を生成する文字列を小文字に変換します。
こちらもご覧ください
適用対象
Explicit(XAttribute to Int64)
- ソース:
- XAttribute.cs
- ソース:
- XAttribute.cs
- ソース:
- XAttribute.cs
- ソース:
- XAttribute.cs
- ソース:
- XAttribute.cs
重要
この API は CLS 準拠ではありません。
この XAttribute の値を 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
パラメーター
- attribute
- XAttribute
XAttributeにキャストするInt64。
返品
このInt64の内容を含むXAttribute。
- 属性
例外
属性に有効な Int64 値が含まれていません。
attribute パラメーターはnull。
例
次の例では、長整数をコンテンツとして持つ属性を作成します。 次に、 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)
この例を実行すると、次の出力が生成されます。
value=9223372036854775807
こちらもご覧ください
適用対象
Explicit(XAttribute to Int32)
- ソース:
- XAttribute.cs
- ソース:
- XAttribute.cs
- ソース:
- XAttribute.cs
- ソース:
- XAttribute.cs
- ソース:
- XAttribute.cs
重要
この API は CLS 準拠ではありません。
この XAttribute の値を 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
パラメーター
- attribute
- XAttribute
XAttributeにキャストするInt32。
返品
このInt32の内容を含むXAttribute。
- 属性
例外
属性に有効な Int32 値が含まれていません。
attribute パラメーターはnull。
例
次の例では、コンテンツとして整数を持つ属性を作成します。 その後、 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)
この例を実行すると、次の出力が生成されます。
value=2147483647
こちらもご覧ください
適用対象
Explicit(XAttribute to Guid)
- ソース:
- XAttribute.cs
- ソース:
- XAttribute.cs
- ソース:
- XAttribute.cs
- ソース:
- XAttribute.cs
- ソース:
- XAttribute.cs
重要
この API は CLS 準拠ではありません。
この XAttribute の値を 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
パラメーター
- attribute
- XAttribute
XAttributeにキャストするGuid。
返品
このGuidの内容を含むXAttribute。
- 属性
例外
属性に有効な Guid 値が含まれていません。
attribute パラメーターはnull。
例
次の例では、GUID をコンテンツとして持つ属性を作成します。 その後、 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)
この例を実行すると、次の出力が生成されます。
value=3c1cc55b-baff-4b7a-9d17-077af3aa5730
こちらもご覧ください
適用対象
Explicit(XAttribute to Double)
- ソース:
- XAttribute.cs
- ソース:
- XAttribute.cs
- ソース:
- XAttribute.cs
- ソース:
- XAttribute.cs
- ソース:
- XAttribute.cs
重要
この API は CLS 準拠ではありません。
この XAttribute の値を 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
パラメーター
- attribute
- XAttribute
XAttributeにキャストするDouble。
返品
このDoubleの内容を含むXAttribute。
- 属性
例外
属性に有効な Double 値が含まれていません。
attribute パラメーターはnull。
例
次の例では、 Double コンテンツを含む属性を作成します。 その後、 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)
この例を実行すると、次の出力が生成されます。
value=1.79769313486231E+308
こちらもご覧ください
適用対象
Explicit(XAttribute to Nullable<Double>)
- ソース:
- XAttribute.cs
- ソース:
- XAttribute.cs
- ソース:
- XAttribute.cs
- ソース:
- XAttribute.cs
- ソース:
- XAttribute.cs
重要
この API は CLS 準拠ではありません。
このXAttributeの値をNullable<T>の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)
パラメーター
- attribute
- XAttribute
XAttributeのNullable<T>にキャストするDouble。
返品
このNullable<T>の内容を含むDoubleのXAttribute。
- 属性
例外
属性に有効な Double 値が含まれていません。
例
次の例では、倍精度浮動小数点コンテンツを持つ属性を作成します。 その後、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"))
この例を実行すると、次の出力が生成されます。
Nullable double: value=1.79769313486231E+308
こちらもご覧ください
適用対象
Explicit(XAttribute to DateTimeOffset)
- ソース:
- XAttribute.cs
- ソース:
- XAttribute.cs
- ソース:
- XAttribute.cs
- ソース:
- XAttribute.cs
- ソース:
- XAttribute.cs
重要
この API は CLS 準拠ではありません。
この XAttribute の値を 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
パラメーター
- attribute
- XAttribute
XAttributeにキャストするDateTimeOffset。
返品
このDateTimeOffsetの内容を含むXAttribute。
- 属性
例外
属性に有効な DateTimeOffset 値が含まれていません。
attribute パラメーターはnull。
例
次の例では、日付と時刻の内容を含む属性を作成します。 その後、それを DateTimeOffset にキャストして値を取得します。
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)
この例を実行すると、次の出力が生成されます。
<Root Att="2006-10-06T12:30:00-07:00" />
dt=10/6/2006 12:30:00 PM -07:00
注釈
この変換演算子は、 XmlConvert クラスを使用して変換を行います。
こちらもご覧ください
適用対象
Explicit(XAttribute to DateTime)
- ソース:
- XAttribute.cs
- ソース:
- XAttribute.cs
- ソース:
- XAttribute.cs
- ソース:
- XAttribute.cs
- ソース:
- XAttribute.cs
重要
この API は CLS 準拠ではありません。
この XAttribute の値を 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
パラメーター
- attribute
- XAttribute
XAttributeにキャストするDateTime。
返品
このDateTimeの内容を含むXAttribute。
- 属性
例外
属性に有効な DateTime 値が含まれていません。
attribute パラメーターはnull。
例
次の例では、日付と時刻の内容を含む属性を作成します。 その後、それを DateTime にキャストして値を取得します。
// 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)
この例を実行すると、次の出力が生成されます。
<Root Att="2006-10-06T12:30:00" />
dt=10/6/2006 12:30:00 PM
-----
OrderDate="October 6, 2006"
OrderDate=10/6/2006
注釈
日付と時刻の内容を含む属性または要素の値空間は、ISO 8601 で説明されている日付と時刻に密接に関連しています。 日付と時刻の内容を含む属性または要素を作成する場合、属性または要素の値は W3C 仕様に従って書式設定されます。 詳細については、W3C 仕様を参照してください。
属性または要素から DateTime にキャストする場合の動作は緩いです。 属性または要素の値が W3C 仕様に従って正確に書式設定されていない場合でも、値は適切に DateTimeに変換されます。
この変換演算子は、 CultureInfo.InvariantCulture を使用して DateTimeから変換します。
こちらもご覧ください
適用対象
Explicit(XAttribute to Boolean)
- ソース:
- XAttribute.cs
- ソース:
- XAttribute.cs
- ソース:
- XAttribute.cs
- ソース:
- XAttribute.cs
- ソース:
- XAttribute.cs
重要
この API は CLS 準拠ではありません。
この XAttribute の値を 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
パラメーター
- attribute
- XAttribute
XAttributeにキャストするBoolean。
返品
このBooleanの内容を含むXAttribute。
- 属性
例外
属性に有効な Boolean 値が含まれていません。
attribute パラメーターはnull。
例
次の例では、 Boolean 値を持つ属性を作成し、それを 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)
この例を実行すると、次の出力が生成されます。
(bool)BoolValue=True
注釈
属性または要素から Boolean に変換する場合、使用できる値は "0"、"1"、およびトリミング後に "true" または "false" を生成する文字列を小文字に変換します。