값이 LinkedList에 있는지 확인하려면 아래 코드를 시도하십시오 -
예
using System; using System.Collections.Generic; public class Demo { public static void Main(){ LinkedList<int> linkedList = new LinkedList<int>(); linkedList.AddLast(25); linkedList.AddLast(50); linkedList.AddLast(100); linkedList.AddLast(200); linkedList.AddLast(400); linkedList.AddLast(500); linkedList.AddLast(550); linkedList.AddLast(600); linkedList.AddLast(800); linkedList.AddLast(1200); Console.WriteLine("Count of nodes = " + linkedList.Count); foreach(int val in linkedList){ Console.WriteLine(val); } Console.WriteLine("Does the LinkedList has node 800? "+linkedList.Contains(800)); } }
출력
이것은 다음과 같은 출력을 생성합니다 -
Count of nodes = 10 25 50 100 200 400 500 550 600 800 1200 Does the LinkedList has node 800? True
예
다른 예를 보겠습니다 -
using System; using System.Collections.Generic; public class Demo { public static void Main(){ LinkedList<string> linkedList = new LinkedList<string>(); linkedList.AddLast("ABC"); linkedList.AddLast("BCD"); linkedList.AddLast("CDE"); linkedList.AddLast("DEF"); linkedList.AddLast("EFG"); linkedList.AddLast("FGH"); linkedList.AddLast("GHI"); linkedList.AddLast("HIJ"); linkedList.AddLast("IJK"); Console.WriteLine("Count of nodes = " + linkedList.Count); foreach(string val in linkedList){ Console.WriteLine(val); } Console.WriteLine("Does the LinkedList has node KLM? "+linkedList.Contains("KLM")); } }
출력
이것은 다음과 같은 출력을 생성합니다 -
Count of nodes = 9 ABC BCD CDE DEF EFG FGH GHI HIJ IJK Does the LinkedList has node KLM? False