Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
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
Programming Articles - Page 2271 of 3366
149 Views
To check if ListDictionary is read-only, 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); } Console.WriteLine("Is the ListDictionary1 having ... Read More
166 Views
To remove all elements from a 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
225 Views
To remove all elements from a HashSet, the code is as follows −Example Live Demousing System; using System.Collections.Generic; public class Demo { public static void Main(String[] args){ HashSet set1 = new HashSet(); set1.Add("A"); set1.Add("B"); set1.Add("C"); set1.Add("D"); set1.Add("E"); set1.Add("F"); set1.Add("G"); set1.Add("H"); Console.WriteLine("Elements in HashSet1..."); foreach (string res in set1){ Console.WriteLine(res); } HashSet set2 = new HashSet(); ... Read More
177 Views
To get a read-only copy of the OrderedDictionary, 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); } OrderedDictionary dict2 ... Read More
164 Views
To check if two Tuple objects are equal, the code is as follows −Example Live Demousing System; public class Demo { public static void Main(String[] args){ var tuple1 = Tuple.Create(150, 400, 500, 700, 100, 1200, 1500); var tuple2 = Tuple.Create(150, 400, 500, 700, 100, 1200, 1500); Console.WriteLine("Is Tuple1 equal to Tuple2? = "+tuple1.Equals(tuple2)); } }OutputThis will produce the following output −Is Tuple1 equal to Tuple2? = TrueExampleLet us see another example − Live Demousing System; public class Demo { public static void Main(String[] args){ var tuple1 = ... Read More
154 Views
To check if two StringBuilder objects are equal, the code is as follows −Example Live Demousing System; using System.Text; public class Demo { public static void Main(String[] args){ StringBuilder strBuilder1 = new StringBuilder("Tim"); StringBuilder strBuilder2 = new StringBuilder("Tom"); StringBuilder strBuilder3 = new StringBuilder(); strBuilder2 = strBuilder3; Console.WriteLine("Is StringBuilder3 equal to StringBuilder2? = "+strBuilder3.Equals(strBuilder2)); } }OutputThis will produce the following output −Is StringBuilder3 equal to StringBuilder2? = TrueExampleLet us see another example − Live Demousing System; using System.Text; public class Demo { public static void ... Read More
178 Views
To check if two String objects have the same value, the code is as follows −Example Live Demousing System; public class Demo { public static void Main(String[] args){ string str1 = "John"; string str2 = "John"; Console.WriteLine("String 1 = "+str1); Console.WriteLine("String 2 = "+str2); Console.WriteLine("String 1 is equal to String 2: {0}", str1.Equals(str2)); } }OutputThis will produce the following output −String 1 = John String 2 = John String 1 is equal to String 2: TrueExampleLet us see another example − Live Demousing System; public ... Read More
191 Views
To create a read-only wrapper for ArrayList, the code is as follows −Example Live Demousing System; using System.Collections; public class Demo { public static void Main(){ ArrayList list = new ArrayList(); list.Add("One"); list.Add("Two"); list.Add("Three"); list.Add("Four"); list.Add("Five"); list.Add("Six"); list.Add("Seven"); list.Add("Eight"); Console.WriteLine("ArrayList elements..."); foreach(string str in list){ Console.WriteLine(str); } Console.WriteLine("ArrayList is read-only? = "+list.IsReadOnly); } }OutputThis will produce ... Read More
460 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
104 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