- 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
275 Views
To get an enumerator that iterates through the SortedList, the code is as follows −Example Live Demousing System; using System.Collections; public class Demo { public static void Main(String[] args){ SortedList sortedList = new SortedList(); sortedList.Add("A", "1"); sortedList.Add("B", "2"); sortedList.Add("C", "3"); sortedList.Add("D", "4"); sortedList.Add("E", "5"); sortedList.Add("F", "6"); sortedList.Add("G", "7"); sortedList.Add("H", "8"); sortedList.Add("I", "9"); sortedList.Add("J", "10"); Console.WriteLine("SortedList elements..."); foreach(DictionaryEntry d in sortedList){ ... Read More
58 Views
To create a HybridDictionary with specified initial size, the code is as follows −Example Live Demousing System; using System.Collections; using System.Collections.Specialized; public class Demo { public static void Main(){ HybridDictionary dict = new HybridDictionary(5); dict.Add("A", "AB"); dict.Add("B", "BC"); dict.Add("C", "DE"); dict.Add("D", "FG"); dict.Add("E", "HI"); Console.WriteLine("Key/Value pairs..."); foreach(DictionaryEntry d in dict) Console.WriteLine("Key = "+d.Key + ", Value = " + d.Value); } }OutputThis will produce the following output −Key/Value pairs... Key = A, ... Read More
62 Views
To create a case-sensitive HybridDictionary with specified initial size, the code is as follows −Example Live Demousing System; using System.Collections; using System.Collections.Specialized; public class Demo { public static void Main(){ HybridDictionary myDict = new HybridDictionary(5, false); myDict.Add("A", "AB"); myDict.Add("B", "BC"); myDict.Add("C", "DE"); myDict.Add("D", "FG"); myDict.Add("e", "fg"); Console.WriteLine("Key/Value pairs..."); foreach(DictionaryEntry de in myDict) Console.WriteLine("Key = "+de.Key + ", Value = " + de.Value); } }OutputThis will produce the following output −Key/Value pairs... Key ... Read More
105 Views
To create HashSet from another Collection, 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(100); set1.Add(200); set1.Add(300); Console.WriteLine("HashSet created from another collection..."); foreach(int i in set1){ Console.WriteLine(i); } HashSet set2 = new HashSet(set1); Console.WriteLine("HashSet created from another collection..."); foreach(int i in set2){ Console.WriteLine(i); } ... Read More
75 Views
To create a Stack from a collection, the code is as follows −Example Live Demousing System; using System.Collections.Generic; public class Demo { public static void Main(){ Stack stack = new Stack(); stack.Push(100); stack.Push(200); stack.Push(300); stack.Push(400); stack.Push(500); stack.Push(600); stack.Push(700); stack.Push(800); stack.Push(900); stack.Push(1000); Console.WriteLine("Stack elements..."); foreach(int val in stack){ Console.WriteLine(val); } Console.WriteLine("Array elements..."); ... Read More
72 Views
To check if two LinkedList objects are equal, the code is as follows −Example Live Demousing System; using System.Collections.Generic; public class Demo { public static void Main(String[] args){ LinkedList list1 = new LinkedList(); list1.AddLast("One"); list1.AddLast("Two"); list1.AddLast("Three"); list1.AddLast("Four"); list1.AddLast("Five"); Console.WriteLine("Elements in LinkedList1..."); foreach (string res in list1){ Console.WriteLine(res); } LinkedList list2 = new LinkedList(); list2.AddLast("India"); list2.AddLast("US"); list2.AddLast("UK"); ... Read More
573 Views
To remove all elements from a list that match the conditions defined by the predicate, the code is as follows −Example Live Demousing System; using System.Collections.Generic; public class Demo { private static bool demo(int i){ return (i == 500); } public static void Main(String[] args){ List list = new List(); list.Add(100); list.Add(500); list.Add(300); list.Add(400); list.Add(500); list.Add(600); list.Add(500); Console.WriteLine("List elements..."); foreach (int i in list){ ... Read More
57 Views
To check if a SortedSet is a superset of the specified collection, 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("CD"); set1.Add("CD"); set1.Add("CD"); set1.Add("CD"); Console.WriteLine("Elements in SortedSet1..."); foreach (string res in set1){ Console.WriteLine(res); } SortedSet set2 = new SortedSet(); set2.Add("BC"); set2.Add("CD"); set2.Add("DE"); ... Read More
67 Views
To check if a HashSet is a superset of the specified collection, 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 ... Read More
78 Views
To check if two HybridDictionary objects are equal, the code is as follows −Example Live Demousing System; using System.Collections; using System.Collections.Specialized; public class Demo { public static void Main(){ HybridDictionary dict1 = new HybridDictionary(); 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("HybridDictionary1 elements..."); foreach(DictionaryEntry d in dict1){ Console.WriteLine(d.Key + " " + d.Value); } HybridDictionary dict2 ... Read More