다음이 정수 노드가 있는 LinkedList라고 가정해 보겠습니다.
int [] num = {29, 40, 67, 89, 198, 234};
LinkedList<int> myList = new LinkedList<int>(num); 이제 목록에서 첫 번째 요소를 제거하려면 RemoveFirst() 메서드를 사용하십시오.
myList.RemoveFirst();
예시
using System;
using System.Collections.Generic;
class Demo {
static void Main() {
int [] num = {29, 40, 67, 89, 198, 234};
LinkedList<int> myList = new LinkedList<int>(num);
foreach (var n in myList) {
Console.WriteLine(n);
}
// removing first node
myList.RemoveFirst();
Console.WriteLine("LinkedList after removing the first node...");
foreach (var n in myList) {
Console.WriteLine(n);
}
}
} 출력
29 40 67 89 198 234 LinkedList after removing the first node... 40 67 89 198 234