- 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
Found 2628 Articles for Csharp
76 Views
To get the number of key/value pairs contained in ListDictionary, the code is as follows−Example Live Demousing System; using System.Collections; using System.Collections.Specialized; public class Demo { public static void Main(){ ListDictionary dict1 = new ListDictionary(); dict1.Add("A", "Books"); dict1.Add("B", "Electronics"); dict1.Add("C", "Smart Wearables"); dict1.Add("D", "Pet Supplies"); dict1.Add("E", "Clothing"); dict1.Add("F", "Footwear"); Console.WriteLine("ListDictionary1 elements..."); foreach(DictionaryEntry d in dict1){ Console.WriteLine(d.Key + " " + d.Value); } ListDictionary ... Read More
179 Views
To remove the first occurrence of specified value from LinkedList, the code is as follows −Example Live Demousing System; using System.Collections.Generic; public class Demo { public static void Main(){ LinkedList list = new LinkedList(); list.AddLast("A"); list.AddLast("B"); list.AddLast("C"); list.AddLast("A"); list.AddLast("E"); list.AddLast("F"); list.AddLast("A"); list.AddLast("H"); list.AddLast("A"); list.AddLast("j"); Console.WriteLine("Count of nodes = " + list.Count); Console.WriteLine("Elements in LinkedList... (Enumerator iterating through LinkedList)"); ... Read More
70 Views
To remove the first occurrence of the object from Collection, the code is as follows −Example Live Demousing System; using System.Collections.ObjectModel; public class Demo { public static void Main(){ Collection col = new Collection(); col.Add("Andy"); col.Add("Kevin"); col.Add("John"); col.Add("Nathan"); col.Add("Nathan"); col.Add("Katie"); col.Add("Barry"); col.Add("Nathan"); col.Add("Mark"); Console.WriteLine("Count of elements = "+ col.Count); Console.WriteLine("Iterating through the collection..."); var enumerator = col.GetEnumerator(); while ... Read More
363 Views
To remove a range of elements from the List, the code is as follows −Example Live Demousing System; using System.Collections.Generic; public class Demo { public static void Main(String[] args){ List list1 = new List(); list1.Add("One"); list1.Add("Two"); list1.Add("Three"); list1.Add("Four"); list1.Add("Five"); Console.WriteLine("Elements in List1..."); foreach (string res in list1){ Console.WriteLine(res); } List list2 = new List(); list2.Add("India"); list2.Add("US"); list2.Add("UK"); ... Read More
293 Views
To remove the specified element from a HashSet, the code is as follows −Example Live Demousing System; using System.Collections.Generic; public class Demo { public static void Main(){ HashSet set1 = new HashSet(); set1.Add("AB"); set1.Add("CD"); set1.Add("EF"); set1.Add("AB"); set1.Add("IJ"); set1.Add("KL"); set1.Add("EF"); set1.Add("OP"); Console.WriteLine("Elements in HashSet1"); foreach(string val in set1){ Console.WriteLine(val); } HashSet set2 = new HashSet(); ... Read More
112 Views
To add key and value into OrderedDictionary collection, the code is as follows −Example Live Demousing System; using System.Collections; using System.Collections.Specialized; public class Demo { public static void Main() { OrderedDictionary dict1 = new OrderedDictionary(); dict1.Add("A", "Books"); dict1.Add("B", "Electronics"); dict1.Add("C", "Smart Wearables"); dict1.Add("D", "Pet Supplies"); dict1.Add("E", "Clothing"); dict1.Add("F", "Footwear"); Console.WriteLine("OrderedDictionary1 elements..."); foreach(DictionaryEntry d in dict1) { Console.WriteLine(d.Key + " " + d.Value); } ... Read More
106 Views
To add element to SortedSet, the code is as follows −Example Live Demousing System; using System.Collections.Generic; public class Demo { public static void Main() { SortedSet set1 = new SortedSet(); set1.Add(100); set1.Add(200); set1.Add(300); set1.Add(400); Console.WriteLine("Elements in SortedSet..."); foreach (int res in set1) { Console.WriteLine(res); } Console.WriteLine("Does the SortedSet contains the element 500? = "+set1.Contains(500)); } }OutputThis will produce the following output −Elements in SortedSet... 100 200 300 400 Does the SortedSet contains the element 500? = FalseExampleLet us ... Read More
66 Views
To get the key at the specified index of a SortedList object, the code is as follows −Example Live Demousing System; using System.Collections; public class Demo { public static void Main(String[] args) { SortedList list1 = new SortedList(); list1.Add("One", 1); list1.Add("Two ", 2); list1.Add("Three ", 3); list1.Add("Four", 4); list1.Add("Five", 5); list1.Add("Six", 6); list1.Add("Seven ", 7); list1.Add("Eight ", 8); list1.Add("Nine", 9); list1.Add("Ten", 10); Console.WriteLine("SortedList1 elements..."); ... Read More
200 Views
To get index of the specified key in a SortedList object, the code is as follows −Example Live Demousing System; using System.Collections; public class Demo { public static void Main(String[] args) { SortedList list = new SortedList(); list.Add("One", "Finance"); list.Add("Two", "Marketing"); list.Add("Three", "Sales"); list.Add("Four", "Purchase"); list.Add("Five", "Operations"); list.Add("Six", "IT"); Console.WriteLine("SortedList elements..."); foreach(DictionaryEntry d in list) { Console.WriteLine(d.Key + " " + d.Value); } ... Read More
51 Views
To get index of the specified value in a SortedList object, the code is as follows −Example Live Demousing System; using System.Collections; public class Demo { public static void Main(String[] args) { SortedList list1 = new SortedList(); list1.Add("One", 1); list1.Add("Two ", 2); list1.Add("Three ", 3); list1.Add("Four", 4); list1.Add("Five", 5); list1.Add("Six", 6); list1.Add("Seven ", 7); list1.Add("Eight ", 8); list1.Add("Nine", 9); list1.Add("Ten", 10); Console.WriteLine("SortedList1 elements..."); ... Read More