- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Samual Sam has Published 2492 Articles
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
Samual Sam
164 Views
Set a list −List myList = new List() { 5, 10, 17, 19, 23, 33 };Let us say you need to find an element that is divisible by 2. For that, use the Find() method −int val = myList.Find(item => item % 2 == ... Read More
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
Samual Sam
8K+ Views
Set a list that has zero elements −List myList = new List();Now check whether the list is empty or null −Console.WriteLine(myList == null);Above, returns “False” i.e. the list is not null - the list is empty.Let us see the complete code −Example Live Demousing System; using System.Collections.Generic; using System.Linq; public class ... Read More
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
Samual Sam
333 Views
Set the strings −List val = new List(); // list of strings val.Add("water"); val.Add("food"); val.Add("air");Use Join method to convert several strings into a single comma-delimited string −string.Join(", ", val.ToArray());Here is the complete code −Example Live Demousing System; using System.Collections.Generic; public class Demo { public static void Main() { ... Read More
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
Samual Sam
451 Views
Here is our list −List val = new List (); // list of strings val.Add("water"); val.Add("food"); val.Add("air");Use the Insert() method to insert an element in the list. With that, also set where you want to add it. We have set the new text at position 1st −val.Insert(1, "shelter");The following ... Read More
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
Samual Sam
2K+ Views
Use the GetRange() method to get the range of elements −Firstly, set a list and add elements −List arr1 = new List(); arr1.Add(10); arr1.Add(20); arr1.Add(30); arr1.Add(40); arr1.Add(50);Now, under a new list get the range of elements between index 1 and 3 −List myList = arr1.GetRange(1, 3);Here is the complete code ... Read More
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
Samual Sam
2K+ Views
A null list exists in C#. To check whether a list is null or not, check them against the null literal. Set a null like this −List myList = null;Now, to check for null, use the equality operator −myList == null;The following is an example −Example Live Demousing System; using System.Collections.Generic; ... Read More
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
Samual Sam
2K+ Views
Firstly, set two arrays −int[] arr1 = { 15, 20, 27, 56 }; int[] arr2 = { 62, 69, 76, 92 };Now create a new list and use AddRange() method to merge −var myList = new List(); myList.AddRange(arr1); myList.AddRange(arr2);After that, convert the merged collection to an array −int[] arr3 = ... Read More
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
Samual Sam
60 Views
Get the location of array elements using the BinarySearch method.Set a string array −string[] str = { "a", "m", "i", "t"};Now get the location of character ‘t’ using Array.BinarySearch −Array.BinarySearch(str, "t");Here is the complete code −Example Live Demousing System; using System.Text; public class Demo { public static void Main() { ... Read More
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
Samual Sam
936 Views
Use the Array.Exists method to check if a value is in an array or not.Set a string array −string[] strArray = new string[] {"keyboard", "screen", "mouse", "charger" };Let’s say you need to find the value “keyboard” in the array. For that, use Array.Exists() −Array.Exists(strArray, ele => ele == "keyboard");It returns ... Read More
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
Samual Sam
107 Views
With TrueForAll() method in arrays, you can check every element for a condition.Let us see an example −Example Live Demousing System; using System.Text; public class Demo { public static void Main() { int[] val = { 97, 45, 76, 21, 89, 45 }; // ... Read More