

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Check if a value is in LinkedList in C#
To check if a value is in LinkedList, try the below code −
Example
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)); } }
Output
This will produce the following output −
Count of nodes = 10 25 50 100 200 400 500 550 600 800 1200 Does the LinkedList has node 800? True
Example
Let us see another example −
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")); } }
Output
This will produce the following output −
Count of nodes = 9 ABC BCD CDE DEF EFG FGH GHI HIJ IJK Does the LinkedList has node KLM? False
- Related Questions & Answers
- Check if two LinkedList objects are equal in C#
- C# program to check if a value is in an array
- JavaScript - Check if value is a percentage?
- Check if value is empty in JavaScript
- C# Program to check whether a node is a LinkedList or not
- Check if a value is present in an Array in Java
- Check if a File is hidden in C#
- Check if a number is Palindrome in C++
- Check if a Matrix is Invertible in C++
- Check if a number is Bleak in C++
- Check if the StringDictionary contains a specific value in C#
- Check if the Hashtable contains a specific value in C#
- Check if a SortedList object contains a specific value in C#
- Check if a number is Full Prime in C++
- Check if a given number is Pronic in C++
Advertisements