다음은 LinkedList입니다.
string [] employees = {"Patrick","Robert","John","Jacob", "Jamie"};
LinkedList<string> list = new LinkedList<string>(employees); 이제 마지막 노드인 "Jamie"를 제거해야 한다고 가정해 보겠습니다. 이를 위해 RemoveLast() 메소드를 사용하십시오.
list.RemoveLast();
예
using System;
using System.Collections.Generic;
class Demo {
static void Main() {
string [] employees = {"Patrick","Robert","John","Jacob", "Jamie"};
LinkedList<string> list = new LinkedList<string>(employees);
foreach (var emp in list) {
Console.WriteLine(emp);
}
// removing last node
list.RemoveLast();
Console.WriteLine("LinkedList after removing last node...");
foreach (var emp in list) {
Console.WriteLine(emp);
}
}
} 출력
Patrick Robert John Jacob Jamie LinkedList after removing last node... Patrick Robert John Jacob