
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
Found 2587 Articles for Csharp

181 Views
To remove all elements from ArrayList, the code is as follows −Example Live Demousing System; using System.Collections; public class Demo { public static void Main(String[] args){ ArrayList list1 = new ArrayList(); list1.Add("A"); list1.Add("B"); list1.Add("C"); list1.Add("D"); list1.Add("E"); list1.Add("F"); list1.Add("G"); list1.Add("H"); list1.Add("I"); Console.WriteLine("Elements in ArrayList1..."); foreach (string res in list1){ Console.WriteLine(res); } ArrayList list2 = new ... Read More

116 Views
To remove all elements from 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 dict = new OrderedDictionary(); dict.Add("A", "Books"); dict.Add("B", "Electronics"); dict.Add("C", "Smart Wearables"); dict.Add("D", "Pet Supplies"); dict.Add("E", "Clothing"); dict.Add("F", "Footwear"); Console.WriteLine("OrderedDictionary elements..."); foreach(DictionaryEntry d in dict){ Console.WriteLine(d.Key + " " + d.Value); } Console.WriteLine("Count of elements in ... Read More

120 Views
To check if ListDictionary is synchronized, the code is as follows −Example Live Demousing System; using System.Collections; using System.Collections.Specialized; public class Demo { public static void Main(){ ListDictionary dict = new ListDictionary(); dict.Add("1", "SUV"); dict.Add("2", "Sedan"); dict.Add("3", "Utility Vehicle"); dict.Add("4", "Compact Car"); dict.Add("5", "SUV"); dict.Add("6", "Sedan"); dict.Add("7", "Utility Vehicle"); dict.Add("8", "Compact Car"); dict.Add("9", "Crossover"); dict.Add("10", "Electric Car"); Console.WriteLine("ListDictionary elements..."); foreach(DictionaryEntry d ... Read More

142 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

156 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

218 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

167 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

154 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

148 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

169 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