XElement.Explicit 연산자

정의

오버로드

Explicit(XElement to Nullable<Int64>)

XElement의 값을 Nullable<T>Int64로 캐스팅합니다.

Explicit(XElement to Nullable<Single>)

XElement의 값을 Nullable<T>Single로 캐스팅합니다.

Explicit(XElement to Nullable<TimeSpan>)

XElement의 값을 Nullable<T>TimeSpan로 캐스팅합니다.

Explicit(XElement to Nullable<UInt32>)

XElement의 값을 Nullable<T>UInt32로 캐스팅합니다.

Explicit(XElement to Nullable<UInt64>)

XElement의 값을 Nullable<T>UInt64로 캐스팅합니다.

Explicit(XElement to UInt32)

XElement의 값을 UInt32으로 캐스팅합니다.

Explicit(XElement to String)

XElement의 값을 String으로 캐스팅합니다.

Explicit(XElement to TimeSpan)

XElement의 값을 TimeSpan으로 캐스팅합니다.

Explicit(XElement to UInt64)

XElement의 값을 UInt64으로 캐스팅합니다.

Explicit(XElement to Nullable<Int32>)

XElement의 값을 Nullable<T>Int32로 캐스팅합니다.

Explicit(XElement to Single)

XElement의 값을 Single으로 캐스팅합니다.

Explicit(XElement to Nullable<Guid>)

XElement의 값을 Nullable<T>Guid로 캐스팅합니다.

Explicit(XElement to Nullable<Boolean>)

XElement의 값을 Nullable<T>Boolean로 캐스팅합니다.

Explicit(XElement to Nullable<Decimal>)

XElement의 값을 Nullable<T>Decimal로 캐스팅합니다.

Explicit(XElement to Boolean)

XElement의 값을 Boolean으로 캐스팅합니다.

Explicit(XElement to DateTime)

XElement의 값을 DateTime으로 캐스팅합니다.

Explicit(XElement to DateTimeOffset)

XAttribute의 값을 DateTimeOffset으로 캐스팅합니다.

Explicit(XElement to Double)

XElement의 값을 Double으로 캐스팅합니다.

Explicit(XElement to Guid)

XElement의 값을 Guid으로 캐스팅합니다.

Explicit(XElement to Decimal)

XElement의 값을 Decimal으로 캐스팅합니다.

Explicit(XElement to Int64)

XElement의 값을 Int64로 캐스팅합니다.

Explicit(XElement to Nullable<Double>)

XElement의 값을 Nullable<T>Double로 캐스팅합니다.

Explicit(XElement to Nullable<DateTime>)

XElement의 값을 Nullable<T>DateTime로 캐스팅합니다.

Explicit(XElement to Nullable<DateTimeOffset>)

XElement의 값을 Nullable<T>DateTimeOffset로 캐스팅합니다.

Explicit(XElement to Int32)

XElement의 값을 Int32로 캐스팅합니다.

Explicit(XElement to Nullable<Int64>)

Source:
XElement.cs
Source:
XElement.cs
Source:
XElement.cs

중요

이 API는 CLS 규격이 아닙니다.

XElement의 값을 Nullable<T>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)

매개 변수

element
XElement

XElementNullable<T>로 캐스팅할 Int64입니다.

반환

Nullable<T>의 콘텐츠가 들어 있는 Int64XElement입니다.

특성

예외

요소가 null이 아니고 유효한 Int64 값을 포함하지 않습니다.

예제

다음 예제에서는 정수 콘텐츠가 긴 요소를 만듭니다. 그런 다음 의 로 캐스팅 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"))

이 예제는 다음과 같은 출력을 생성합니다.

Nullable ulong: value=9223372036854775807

추가 정보

적용 대상

Explicit(XElement to Nullable<Single>)

Source:
XElement.cs
Source:
XElement.cs
Source:
XElement.cs

중요

이 API는 CLS 규격이 아닙니다.

XElement의 값을 Nullable<T>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)

매개 변수

element
XElement

XElementNullable<T>로 캐스팅할 Single입니다.

반환

Nullable<T>의 콘텐츠가 들어 있는 SingleXElement입니다.

특성

예외

요소가 null이 아니고 유효한 Single 값을 포함하지 않습니다.

예제

다음 예제에서는 단정밀도 부동 소수점 콘텐츠가 있는 요소를 만듭니다. 그런 다음 의 로 캐스팅 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"))

이 예제는 다음과 같은 출력을 생성합니다.

Nullable Single: value=3.402823E+38

추가 정보

적용 대상

Explicit(XElement to Nullable<TimeSpan>)

Source:
XElement.cs
Source:
XElement.cs
Source:
XElement.cs

중요

이 API는 CLS 규격이 아닙니다.

XElement의 값을 Nullable<T>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)

매개 변수

element
XElement

XElementNullable<T>로 캐스팅할 TimeSpan입니다.

반환

Nullable<T>의 콘텐츠가 들어 있는 TimeSpanXElement입니다.

특성

예외

요소가 null이 아니고 유효한 TimeSpan 값을 포함하지 않습니다.

예제

다음 예제에서는 시간 범위 콘텐츠가 있는 요소를 만듭니다. 그런 다음 의 로 캐스팅 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"))

이 예제는 다음과 같은 출력을 생성합니다.

Nullable TimeSpan: value=01:05:30

설명

시간 범위 콘텐츠를 포함하는 특성 또는 요소의 값 공간은 ISO 8601에 설명된 기간 콘텐츠와 밀접한 관련이 있습니다. 시간 범위 콘텐츠를 포함하는 특성 또는 요소를 만들 때 특성 또는 요소 값은 W3C 사양에 따라 형식이 지정됩니다. 자세한 내용은 W3C 사양을 참조하세요.

특성 또는 요소에서 의 TimeSpan 로 캐스팅할 Nullable<T> 때 동작이 느슨합니다. 특성 또는 요소 값이 W3C 사양에 따라 정확히 형식이 지정되지 않더라도 값은 의 TimeSpanNullable<T> 적절하게 변환됩니다.

추가 정보

적용 대상

Explicit(XElement to Nullable<UInt32>)

Source:
XElement.cs
Source:
XElement.cs
Source:
XElement.cs

중요

이 API는 CLS 규격이 아닙니다.

XElement의 값을 Nullable<T>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)

매개 변수

element
XElement

XElementNullable<T>로 캐스팅할 UInt32입니다.

반환

Nullable<T>의 콘텐츠가 들어 있는 UInt32XElement입니다.

특성

예외

요소가 null이 아니고 유효한 UInt32 값을 포함하지 않습니다.

예제

다음 예제에서는 부호 없는 정수 콘텐츠가 있는 요소를 만듭니다. 그런 다음 의 로 캐스팅 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"))

이 예제는 다음과 같은 출력을 생성합니다.

Nullable uint: value=4294967295

추가 정보

적용 대상

Explicit(XElement to Nullable<UInt64>)

Source:
XElement.cs
Source:
XElement.cs
Source:
XElement.cs

중요

이 API는 CLS 규격이 아닙니다.

XElement의 값을 Nullable<T>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)

매개 변수

element
XElement

XElementNullable<T>로 캐스팅할 UInt64입니다.

반환

Nullable<T>의 콘텐츠가 들어 있는 UInt64XElement입니다.

특성

예외

요소가 null이 아니고 유효한 UInt64 값을 포함하지 않습니다.

예제

다음 예제에서는 부호 없는 긴 정수 콘텐츠가 있는 요소를 만듭니다. 그런 다음 의 로 캐스팅 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"))

이 예제는 다음과 같은 출력을 생성합니다.

Nullable ulong: value=9223372036854775807

추가 정보

적용 대상

Explicit(XElement to UInt32)

Source:
XElement.cs
Source:
XElement.cs
Source:
XElement.cs

중요

이 API는 CLS 규격이 아닙니다.

XElement의 값을 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

매개 변수

element
XElement

XElement으로 캐스팅할 UInt32입니다.

반환

UInt32의 콘텐츠가 들어 있는 XElement입니다.

특성

예외

요소에 유효한 UInt32 값이 들어 있지 않은 경우

element 매개 변수가 null인 경우

예제

다음 예제에서는 부호 없는 정수 콘텐츠가 있는 요소를 만듭니다. 그런 다음 로 캐스팅 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)

이 예제는 다음과 같은 출력을 생성합니다.

value=4294967295

추가 정보

적용 대상

Explicit(XElement to String)

Source:
XElement.cs
Source:
XElement.cs
Source:
XElement.cs

중요

이 API는 CLS 규격이 아닙니다.

XElement의 값을 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

매개 변수

element
XElement

XElement으로 캐스팅할 String입니다.

반환

String의 콘텐츠가 들어 있는 XElement입니다.

특성

예제

다음 예제에서는 문자열 콘텐츠가 있는 요소를 만듭니다. 그런 다음 로 캐스팅 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)

이 예제는 다음과 같은 출력을 생성합니다.

(string)root=abc def ghi

설명

XElement 자식이 있는 경우 요소의 모든 텍스트와 하위 텍스트의 연결된 문자열 값이 반환됩니다.

추가 정보

적용 대상

Explicit(XElement to TimeSpan)

Source:
XElement.cs
Source:
XElement.cs
Source:
XElement.cs

중요

이 API는 CLS 규격이 아닙니다.

XElement의 값을 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

매개 변수

element
XElement

XElement으로 캐스팅할 TimeSpan입니다.

반환

TimeSpan의 콘텐츠가 들어 있는 XElement입니다.

특성

예외

요소에 유효한 TimeSpan 값이 들어 있지 않은 경우

element 매개 변수가 null인 경우

예제

다음 예제에서는 시간 범위 콘텐츠가 있는 요소를 만듭니다. 그런 다음 로 캐스팅 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)

이 예제는 다음과 같은 출력을 생성합니다.

value=01:05:30

설명

시간 범위 콘텐츠가 포함된 특성 또는 요소의 값 공간은 ISO 8601에 설명된 대로 기간 콘텐츠와 밀접한 관련이 있습니다. 시간 범위 콘텐츠가 포함된 특성 또는 요소를 만들 때 특성 또는 요소 값은 W3C 사양에 따라 형식이 지정됩니다. 자세한 내용은 W3C 사양을 참조하세요.

특성 또는 요소에서 로 TimeSpan 캐스팅할 때 동작이 느슨합니다. 특성 또는 요소 값이 W3C 사양에 따라 정확히 형식이 지정되지 않더라도 값은 로 적절하게 변환 TimeSpan됩니다.

추가 정보

적용 대상

Explicit(XElement to UInt64)

Source:
XElement.cs
Source:
XElement.cs
Source:
XElement.cs

중요

이 API는 CLS 규격이 아닙니다.

XElement의 값을 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

매개 변수

element
XElement

XElement으로 캐스팅할 UInt64입니다.

반환

UInt64의 콘텐츠가 들어 있는 XElement입니다.

특성

예외

요소에 유효한 UInt64 값이 들어 있지 않은 경우

element 매개 변수가 null인 경우

element이(가) null인 경우

예제

다음 예제에서는 부호 없는 긴 정수 콘텐츠가 있는 요소를 만듭니다. 그런 다음 로 캐스팅 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)

이 예제는 다음과 같은 출력을 생성합니다.

value=18446744073709551615

추가 정보

적용 대상

Explicit(XElement to Nullable<Int32>)

Source:
XElement.cs
Source:
XElement.cs
Source:
XElement.cs

중요

이 API는 CLS 규격이 아닙니다.

XElement의 값을 Nullable<T>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)

매개 변수

element
XElement

XElementNullable<T>로 캐스팅할 Int32입니다.

반환

Nullable<T>의 콘텐츠가 들어 있는 Int32XElement입니다.

특성

예외

요소가 null이 아니고 유효한 Int32 값을 포함하지 않습니다.

예제

다음 예제에서는 부호 없는 정수 콘텐츠가 있는 요소를 만듭니다. 그런 다음 의 로 캐스팅 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"))

이 예제는 다음과 같은 출력을 생성합니다.

Nullable integer: value=2147483647

추가 정보

적용 대상

Explicit(XElement to Single)

Source:
XElement.cs
Source:
XElement.cs
Source:
XElement.cs

중요

이 API는 CLS 규격이 아닙니다.

XElement의 값을 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

매개 변수

element
XElement

XElement으로 캐스팅할 Single입니다.

반환

Single의 콘텐츠가 들어 있는 XElement입니다.

특성

예외

요소에 유효한 Single 값이 들어 있지 않은 경우

element 매개 변수가 null인 경우

element이(가) null인 경우

예제

다음 예제에서는 단일 정밀도 부동 소수점 콘텐츠가 있는 요소를 만듭니다. 그런 다음 로 캐스팅 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)

이 예제는 다음과 같은 출력을 생성합니다.

value=3.402823E+38

추가 정보

적용 대상

Explicit(XElement to Nullable<Guid>)

Source:
XElement.cs
Source:
XElement.cs
Source:
XElement.cs

중요

이 API는 CLS 규격이 아닙니다.

XElement의 값을 Nullable<T>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)

매개 변수

element
XElement

XElementNullable<T>로 캐스팅할 Guid입니다.

반환

Nullable<T>의 콘텐츠가 들어 있는 GuidXElement입니다.

특성

예외

요소가 null이 아니고 유효한 Guid 값을 포함하지 않습니다.

예제

다음 예제에서는 guid 콘텐츠가 있는 요소를 만듭니다. 그런 다음 의 로 캐스팅 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"))

이 예제는 다음과 같은 출력을 생성합니다.

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

추가 정보

적용 대상

Explicit(XElement to Nullable<Boolean>)

Source:
XElement.cs
Source:
XElement.cs
Source:
XElement.cs

중요

이 API는 CLS 규격이 아닙니다.

XElement의 값을 Nullable<T>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)

매개 변수

element
XElement

XElementNullable<T>로 캐스팅할 Boolean입니다.

반환

Nullable<T>의 콘텐츠가 들어 있는 BooleanXElement입니다.

특성

예외

요소가 null이 아니고 유효한 Boolean 값을 포함하지 않습니다.

예제

다음 예제에서는 부울 콘텐츠가 있는 요소를 만듭니다. 그런 다음 의 로 캐스팅 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"))

이 예제는 다음과 같은 출력을 생성합니다.

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

설명

특성 또는 요소에서 의 Boolean 로 변환할 Nullable<T> 때 허용되는 값은 "0", "1"이며 트리밍 후 "true" 또는 "false"를 생성하는 문자열은 소문자입니다.

추가 정보

적용 대상

Explicit(XElement to Nullable<Decimal>)

Source:
XElement.cs
Source:
XElement.cs
Source:
XElement.cs

중요

이 API는 CLS 규격이 아닙니다.

XElement의 값을 Nullable<T>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)

매개 변수

element
XElement

XElementNullable<T>로 캐스팅할 Decimal입니다.

반환

Nullable<T>의 콘텐츠가 들어 있는 DecimalXElement입니다.

특성

예외

요소가 null이 아니고 유효한 Decimal 값을 포함하지 않습니다.

예제

다음 예제에서는 10진수 콘텐츠가 있는 요소를 만듭니다. 그런 다음 의 로 캐스팅 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"))

이 예제는 다음과 같은 출력을 생성합니다.

Nullable decimal: value=79228162514264337593543950335

추가 정보

적용 대상

Explicit(XElement to Boolean)

Source:
XElement.cs
Source:
XElement.cs
Source:
XElement.cs

중요

이 API는 CLS 규격이 아닙니다.

XElement의 값을 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

매개 변수

element
XElement

XElement으로 캐스팅할 Boolean입니다.

반환

Boolean의 콘텐츠가 들어 있는 XElement입니다.

특성

예외

요소에 유효한 Boolean 값이 들어 있지 않은 경우

element 매개 변수가 null인 경우

예제

다음 예제에서는 부울 값이 있는 일부 요소를 만듭니다. 그런 다음, 으로 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)

이 예제는 다음과 같은 출력을 생성합니다.

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

설명

특성 또는 요소에서 로 변환할 Boolean 때 허용되는 값은 "0", "1"이며 트리밍 후 "true" 또는 "false"를 생성하는 문자열은 소문자입니다.

추가 정보

적용 대상

Explicit(XElement to DateTime)

Source:
XElement.cs
Source:
XElement.cs
Source:
XElement.cs

중요

이 API는 CLS 규격이 아닙니다.

XElement의 값을 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

매개 변수

element
XElement

XElement으로 캐스팅할 DateTime입니다.

반환

DateTime의 콘텐츠가 들어 있는 XElement입니다.

특성

예외

요소에 유효한 DateTime 값이 들어 있지 않은 경우

element 매개 변수가 null인 경우

element이(가) 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 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)

이 예제는 다음과 같은 출력을 생성합니다.

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

설명

날짜 및 시간 콘텐츠를 포함하는 특성 또는 요소의 값 공간은 ISO 8601에 설명된 날짜 및 시간과 밀접한 관련이 있습니다. 날짜 및 시간 콘텐츠를 포함하는 특성 또는 요소를 만들 때 특성 또는 요소 값은 W3C 사양에 따라 형식이 지정됩니다. 자세한 내용은 W3C 사양을 참조하세요.

특성 또는 요소에서 로 DateTime 캐스팅할 때 동작이 느슨합니다. 특성 또는 요소 값이 W3C 사양에 따라 정확히 형식이 지정되지 않더라도 값은 로 적절하게 변환 DateTime됩니다.

이 변환 연산자는 를 사용하여 CultureInfo.InvariantCulture 에서 변환합니다 DateTime.

추가 정보

적용 대상

Explicit(XElement to DateTimeOffset)

Source:
XElement.cs
Source:
XElement.cs
Source:
XElement.cs

중요

이 API는 CLS 규격이 아닙니다.

XAttribute의 값을 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

매개 변수

element
XElement

XElement으로 캐스팅할 DateTimeOffset입니다.

반환

DateTimeOffset의 콘텐츠가 들어 있는 XElement입니다.

특성

예외

요소에 유효한 DateTimeOffset 값이 들어 있지 않은 경우

element 매개 변수가 null인 경우

element이(가) null인 경우

예제

다음 예제에서는 날짜 및 시간 콘텐츠를 사용하여 요소를 만듭니다. 그런 다음 로 캐스팅하여 DateTimeOffset 값을 검색합니다.

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)

이 예제는 다음과 같은 출력을 생성합니다.

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

설명

이 변환 연산자는 클래스를 XmlConvert 사용하여 변환을 수행합니다.

추가 정보

적용 대상

Explicit(XElement to Double)

Source:
XElement.cs
Source:
XElement.cs
Source:
XElement.cs

중요

이 API는 CLS 규격이 아닙니다.

XElement의 값을 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

매개 변수

element
XElement

XElement으로 캐스팅할 Double입니다.

반환

Double의 콘텐츠가 들어 있는 XElement입니다.

특성

예외

요소에 유효한 Double 값이 들어 있지 않은 경우

element 매개 변수가 null인 경우

element이(가) null인 경우

예제

다음 예제에서는 콘텐츠를 사용하여 특성을 double 만듭니다. 그런 다음 로 캐스팅 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)

이 예제는 다음과 같은 출력을 생성합니다.

value=1.79769313486231E+308

추가 정보

적용 대상

Explicit(XElement to Guid)

Source:
XElement.cs
Source:
XElement.cs
Source:
XElement.cs

중요

이 API는 CLS 규격이 아닙니다.

XElement의 값을 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

매개 변수

element
XElement

XElement으로 캐스팅할 Guid입니다.

반환

Guid의 콘텐츠가 들어 있는 XElement입니다.

특성

예외

요소에 유효한 Guid 값이 들어 있지 않은 경우

element 매개 변수가 null인 경우

element이(가) null인 경우

예제

다음 예제에서는 guid를 콘텐츠로 사용하여 요소를 만듭니다. 그런 다음 로 캐스팅 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)

이 예제는 다음과 같은 출력을 생성합니다.

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

추가 정보

적용 대상

Explicit(XElement to Decimal)

Source:
XElement.cs
Source:
XElement.cs
Source:
XElement.cs

중요

이 API는 CLS 규격이 아닙니다.

XElement의 값을 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

매개 변수

element
XElement

XElement으로 캐스팅할 Decimal입니다.

반환

Decimal의 콘텐츠가 들어 있는 XElement입니다.

특성

예외

요소에 유효한 Decimal 값이 들어 있지 않은 경우

element 매개 변수가 null인 경우

element이(가) null인 경우

예제

다음 예제에서는 10진수 값으로 요소를 만듭니다. 그런 다음 로 캐스팅 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)

이 예제는 다음과 같은 출력을 생성합니다.

value=79228162514264337593543950335

추가 정보

적용 대상

Explicit(XElement to Int64)

Source:
XElement.cs
Source:
XElement.cs
Source:
XElement.cs

중요

이 API는 CLS 규격이 아닙니다.

XElement의 값을 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

매개 변수

element
XElement

XElement으로 캐스팅할 Int64입니다.

반환

Int64의 콘텐츠가 들어 있는 XElement입니다.

특성

예외

요소에 유효한 Int64 값이 들어 있지 않은 경우

element 매개 변수가 null인 경우

element이(가) null인 경우

예제

다음 예제에서는 긴 정수의 요소를 콘텐츠로 만듭니다. 그런 다음 로 캐스팅 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)

이 예제는 다음과 같은 출력을 생성합니다.

value=9223372036854775807

추가 정보

적용 대상

Explicit(XElement to Nullable<Double>)

Source:
XElement.cs
Source:
XElement.cs
Source:
XElement.cs

중요

이 API는 CLS 규격이 아닙니다.

XElement의 값을 Nullable<T>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)

매개 변수

element
XElement

XElementNullable<T>로 캐스팅할 Double입니다.

반환

Nullable<T>의 콘텐츠가 들어 있는 DoubleXElement입니다.

특성

예외

요소가 null이 아니고 유효한 Double 값을 포함하지 않습니다.

예제

다음 예제에서는 배정밀도 부동 소수점 콘텐츠가 있는 요소를 만듭니다. 그런 다음 의 로 캐스팅 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"))

이 예제는 다음과 같은 출력을 생성합니다.

Nullable double: value=1.79769313486231E+308

추가 정보

적용 대상

Explicit(XElement to Nullable<DateTime>)

Source:
XElement.cs
Source:
XElement.cs
Source:
XElement.cs

중요

이 API는 CLS 규격이 아닙니다.

XElement의 값을 Nullable<T>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)

매개 변수

element
XElement

XElementNullable<T>로 캐스팅할 DateTime입니다.

반환

Nullable<T>의 콘텐츠가 들어 있는 DateTimeXElement입니다.

특성

예외

요소가 null이 아니고 유효한 DateTime 값을 포함하지 않습니다.

예제

다음 예제에서는 날짜 및 시간을 콘텐츠로 사용하여 요소를 만듭니다. 그런 다음 의 로 캐스팅 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"))

이 예제는 다음과 같은 출력을 생성합니다.

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

설명

날짜 및 시간 콘텐츠를 포함하는 특성 또는 요소의 값 공간은 ISO 8601에 설명된 날짜 및 시간과 밀접한 관련이 있습니다. 날짜 및 시간 콘텐츠를 포함하는 특성 또는 요소를 만들 때 특성 또는 요소 값은 W3C 사양에 따라 형식이 지정됩니다. 자세한 내용은 W3C 사양을 참조하세요.

특성 또는 요소에서 의 DateTime 로 캐스팅할 Nullable<T> 때 동작이 느슨합니다. 특성 또는 요소 값이 W3C 사양에 따라 정확히 형식이 지정되지 않더라도 값은 의 DateTimeNullable<T> 적절하게 변환됩니다.

이 변환 연산자는 를 사용하여 CultureInfo.InvariantCulture 에서 변환합니다 DateTime.

추가 정보

적용 대상

Explicit(XElement to Nullable<DateTimeOffset>)

Source:
XElement.cs
Source:
XElement.cs
Source:
XElement.cs

중요

이 API는 CLS 규격이 아닙니다.

XElement의 값을 Nullable<T>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)

매개 변수

element
XElement

XElementNullable<T>로 캐스팅할 DateTimeOffset입니다.

반환

Nullable<T>의 콘텐츠가 들어 있는 DateTimeOffsetXElement입니다.

특성

예외

요소가 null이 아니고 유효한 DateTimeOffset 값을 포함하지 않습니다.

예제

다음 예제에서는 날짜 및 시간 콘텐츠를 사용하여 요소를 만듭니다. 그런 다음 에 캐스팅하여 Nullable<T>DateTimeOffset 값을 검색합니다.

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)

이 예제는 다음과 같은 출력을 생성합니다.

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

설명

이 변환 연산자는 클래스를 XmlConvert 사용하여 변환을 수행합니다.

추가 정보

적용 대상

Explicit(XElement to Int32)

Source:
XElement.cs
Source:
XElement.cs
Source:
XElement.cs

중요

이 API는 CLS 규격이 아닙니다.

XElement의 값을 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

매개 변수

element
XElement

XElement으로 캐스팅할 Int32입니다.

반환

Int32의 콘텐츠가 들어 있는 XElement입니다.

특성

예외

요소에 유효한 Int32 값이 들어 있지 않은 경우

element 매개 변수가 null인 경우

예제

다음 예제에서는 정수와 함께 요소를 콘텐츠로 만듭니다. 그런 다음 로 캐스팅 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)

이 예제는 다음과 같은 출력을 생성합니다.

value=2147483647

추가 정보

적용 대상