Extensions.Remove 메서드

정의

오버로드

Remove(IEnumerable<XAttribute>)

부모 요소에서 소스 컬렉션의 모든 특성을 제거합니다.

Remove<T>(IEnumerable<T>)

부모 노드에서 소스 컬렉션의 모든 노드를 제거합니다.

Remove(IEnumerable<XAttribute>)

부모 요소에서 소스 컬렉션의 모든 특성을 제거합니다.

public:
[System::Runtime::CompilerServices::Extension]
 static void Remove(System::Collections::Generic::IEnumerable<System::Xml::Linq::XAttribute ^> ^ source);
public static void Remove (this System.Collections.Generic.IEnumerable<System.Xml.Linq.XAttribute> source);
public static void Remove (this System.Collections.Generic.IEnumerable<System.Xml.Linq.XAttribute?> source);
static member Remove : seq<System.Xml.Linq.XAttribute> -> unit
<Extension()>
Public Sub Remove (source As IEnumerable(Of XAttribute))

매개 변수

source
IEnumerable<XAttribute>

소스 컬렉션이 들어 있는 IEnumerable<T>XAttribute입니다.

예제

다음 예제에서는 특성 컬렉션을 검색한 다음 이 메서드를 호출하여 부모 요소에서 제거합니다.

XElement root = new XElement("Root",  
    new XAttribute("Att1", 1),  
    new XAttribute("Att2", 2),  
    new XAttribute("Att3", 3),  
    new XAttribute("Att4", 4),  
    new XAttribute("Att5", 5)  
);  

IEnumerable<XAttribute> atList =  
    from at in root.Attributes()  
    where (int)at >= 3  
    select at;  

atList.Remove();  

Console.WriteLine(root);  
Dim root As XElement = <Root Att1="1" Att2="2" Att3="3" Att4="4" Att5="5"/>  

Dim atList = From at In root.Attributes _  
             Where at.Value >= 3 _  
             Select at  

atList.Remove()  

Console.WriteLine(root)  

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

<Root Att1="1" Att2="2" />  

설명

이 메서드는 스냅샷 의미 체계를 사용합니다. 즉, 부모로부터 연결을 끊기 전에 원본 컬렉션의 특성을 a System.Collections.Generic.List<T> 에 복사합니다. 이는 혼합 명령적/선언적 코드와 관련된 문제를 방지하는 데 필요합니다. 자세한 내용은 혼합 선언적 코드/명령적 코드 버그(LINQ to XML)를 참조하세요.

추가 정보

적용 대상

Remove<T>(IEnumerable<T>)

부모 노드에서 소스 컬렉션의 모든 노드를 제거합니다.

public:
generic <typename T>
 where T : System::Xml::Linq::XNode[System::Runtime::CompilerServices::Extension]
 static void Remove(System::Collections::Generic::IEnumerable<T> ^ source);
public static void Remove<T> (this System.Collections.Generic.IEnumerable<T> source) where T : System.Xml.Linq.XNode;
public static void Remove<T> (this System.Collections.Generic.IEnumerable<T?> source) where T : System.Xml.Linq.XNode;
static member Remove : seq<'T (requires 'T :> System.Xml.Linq.XNode)> -> unit (requires 'T :> System.Xml.Linq.XNode)
<Extension()>
Public Sub Remove(Of T As XNode) (source As IEnumerable(Of T))

형식 매개 변수

T

XNode로 제한된 source의 개체 형식입니다.

매개 변수

source
IEnumerable<T>

소스 컬렉션이 들어 있는 IEnumerable<T>XNode입니다.

예제

다음 예제에서는 요소 컬렉션을 검색합니다. 그런 다음 이 메서드를 호출하여 부모 요소에서 요소를 제거합니다.

XElement root = new XElement("Root",  
    new XElement("Data", 1),  
    new XElement("Data", 2),  
    new XElement("Data", 3),  
    new XElement("Data", 4),  
    new XElement("Data", 5)  
);  

IEnumerable<XElement> elList =  
    from el in root.Elements()  
    where (int)el >= 3  
    select el;  

elList.Remove();  

Console.WriteLine(root);  
Dim root As XElement = _  
    <Root>  
        <Data>1</Data>  
        <Data>2</Data>  
        <Data>3</Data>  
        <Data>4</Data>  
        <Data>5</Data>  
    </Root>  

Dim elList = From el In root.Elements _  
             Where el.Value >= 3 _  
             Select el  

elList.Remove()  

Console.WriteLine(root)  

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

<Root>  
  <Data>1</Data>  
  <Data>2</Data>  
</Root>  

설명

이 메서드는 스냅샷 의미 체계를 사용합니다. 즉, 부모로부터 연결을 끊기 전에 원본 컬렉션의 특성을 a List<T> 에 복사합니다. 이는 혼합 명령적/선언적 코드와 관련된 문제를 방지하는 데 필요합니다. 자세한 내용은 혼합 선언적 코드/명령적 코드 버그(LINQ to XML)를 참조하세요.

추가 정보

적용 대상