Share via


XAttribute.Explicit 연산자

정의

오버로드

Explicit(XAttribute to Nullable<Int64>)

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

Explicit(XAttribute to Nullable<Single>)

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

Explicit(XAttribute to Nullable<TimeSpan>)

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

Explicit(XAttribute to Nullable<UInt32>)

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

Explicit(XAttribute to Nullable<UInt64>)

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

Explicit(XAttribute to TimeSpan)

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

Explicit(XAttribute to String)

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

Explicit(XAttribute to Nullable<Int32>)

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

Explicit(XAttribute to UInt32)

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

Explicit(XAttribute to UInt64)

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

Explicit(XAttribute to Single)

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

Explicit(XAttribute to Nullable<Guid>)

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

Explicit(XAttribute to Nullable<Decimal>)

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

Explicit(XAttribute to Decimal)

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

Explicit(XAttribute to Nullable<DateTimeOffset>)

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

Explicit(XAttribute to Nullable<DateTime>)

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

Explicit(XAttribute to Nullable<Boolean>)

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

Explicit(XAttribute to Int64)

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

Explicit(XAttribute to Int32)

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

Explicit(XAttribute to Guid)

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

Explicit(XAttribute to Double)

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

Explicit(XAttribute to Nullable<Double>)

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

Explicit(XAttribute to DateTimeOffset)

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

Explicit(XAttribute to DateTime)

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

Explicit(XAttribute to Boolean)

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

Explicit(XAttribute to Nullable<Int64>)

중요

이 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

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

반환

Nullable<Int64>

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

특성

예외

특성에 유효한 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>)

중요

이 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

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

반환

Nullable<Single>

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

특성

예외

특성에 유효한 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>)

중요

이 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

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

반환

Nullable<TimeSpan>

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

특성

예외

특성에 유효한 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 사양을 참조하세요.

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

추가 정보

적용 대상

Explicit(XAttribute to Nullable<UInt32>)

중요

이 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

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

반환

Nullable<UInt32>

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

특성

예외

특성에 유효한 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>)

중요

이 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

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

반환

Nullable<UInt64>

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

특성

예외

특성에 유효한 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)

중요

이 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

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)

중요

이 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

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>)

중요

이 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

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

반환

Nullable<Int32>

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

특성

예제

다음 예제에서는 정수 콘텐츠가 있는 특성을 만듭니다. 그런 다음 , .로 캐스팅하여 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)

중요

이 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

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)

중요

이 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

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)

중요

이 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

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>)

중요

이 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

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

반환

Nullable<Guid>

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

특성

예외

특성에 유효한 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>)

중요

이 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

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

반환

Nullable<Decimal>

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

특성

예외

특성에 유효한 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)

중요

이 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

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>)

중요

이 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

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

반환

Nullable<DateTimeOffset>

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

특성

예외

특성에 유효한 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>)

중요

이 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

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

반환

Nullable<DateTime>

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

특성

예외

특성에 유효한 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 사양을 참조하세요.

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

이 변환 연산자는 CultureInfo.InvariantCulture DateTime.

추가 정보

적용 대상

Explicit(XAttribute to Nullable<Boolean>)

중요

이 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

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

반환

Nullable<Boolean>

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

특성

예외

특성에 유효한 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)

중요

이 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

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)

중요

이 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

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)

중요

이 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

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)

중요

이 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

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>)

중요

이 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

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

반환

Nullable<Double>

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

특성

예외

특성에 유효한 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)

중요

이 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

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)

중요

이 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

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)

중요

이 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

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"를 생성하는 문자열을 소문자로 변환합니다.

추가 정보

적용 대상