XObject.RemoveAnnotations 메서드

정의

오버로드

RemoveAnnotations(Type)

XObject에서 지정된 형식의 주석을 제거합니다.

RemoveAnnotations<T>()

XObject에서 지정된 형식의 주석을 제거합니다.

RemoveAnnotations(Type)

XObject에서 지정된 형식의 주석을 제거합니다.

public void RemoveAnnotations (Type type);

매개 변수

type
Type

제거할 주석의 형식입니다.

예제

다음 예제에서는 네 개의 주석이 있는 요소를 만듭니다. 그런 다음 이 메서드를 사용하여 두 메서드를 제거합니다.

public class MyAnnotation {  
    private string tag;  
    public string Tag {get{return tag;} set{tag=value;}}  
    public MyAnnotation(string tag) {  
        this.tag = tag;  
    }  
}  

class Program  
{  
    static void Main(string[] args)  
    {     
        XElement root = new XElement("Root", "content");  
        root.AddAnnotation(new MyAnnotation("T1"));  
        root.AddAnnotation(new MyAnnotation("T2"));  
        root.AddAnnotation("abc");  
        root.AddAnnotation("def");  

        Console.WriteLine("Count before removing: {0}", root.Annotations<object>().Count());  
        root.RemoveAnnotations(typeof(MyAnnotation));  
        Console.WriteLine("Count after removing: {0}", root.Annotations<object>().Count());  
    }  
}  

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

Count before removing: 4  
Count after removing: 2  

추가 정보

적용 대상

RemoveAnnotations<T>()

XObject에서 지정된 형식의 주석을 제거합니다.

public void RemoveAnnotations<T> () where T : class;

형식 매개 변수

T

제거할 주석의 형식입니다.

예제

다음 예제에서는 네 개의 주석이 있는 요소를 만듭니다. 그런 다음 이 메서드를 사용하여 두 메서드를 제거합니다.

public class MyAnnotation {  
    private string tag;  
    public string Tag {get{return tag;} set{tag=value;}}  
    public MyAnnotation(string tag) {  
        this.tag = tag;  
    }  
}  

class Program {  
    static void Main(string[] args) {     
        XElement root = new XElement("Root", "content");  
        root.AddAnnotation(new MyAnnotation("T1"));  
        root.AddAnnotation(new MyAnnotation("T2"));  
        root.AddAnnotation("abc");  
        root.AddAnnotation("def");  

        Console.WriteLine("Count before removing: {0}", root.Annotations<object>().Count());  
        root.RemoveAnnotations<MyAnnotation>();  
        Console.WriteLine("Count after removing: {0}", root.Annotations<object>().Count());  
    }  
}  

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

Count before removing: 4  
Count after removing: 2  

추가 정보

적용 대상