
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

138 Views
To remove all the strings from the StringCollection, the code is as follows −Example Live Demousing System; using System.Collections.Specialized; public class Demo { public static void Main() { StringCollection stringCol = new StringCollection(); String[] arr = new String[] { "100", "200", "300", "400", "500" }; Console.WriteLine("Array elements..."); foreach (string res in arr) { Console.WriteLine(res); } stringCol.AddRange(arr); Console.WriteLine("Does the specified string is in the StringCollection? = "+stringCol.Contains("800")); Console.WriteLine("Total number of elements = "+stringCol.Count); ... Read More

160 Views
To remove all the 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"); ... Read More

119 Views
To get the number of elements contained in 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("Kevin"); col.Add("Mary"); 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

150 Views
To get or set the element ate the specified index in 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 list = new List(); list.Add("100"); list.Add("200"); list.Add("300"); list.Add("400"); list.Add("500"); list.Add("600"); list.Add("700"); list.Add("800"); list.Add("900"); list.Add("1000"); Console.WriteLine("Element at index 0 = " + list[0]); Console.WriteLine("Element at index 1 ... Read More

89 Views
To get or set the element at the specified index in StringCollection, the code is as follows −Example Live Demousing System; using System.Collections.Specialized; public class Demo { public static void Main() { StringCollection strCol = new StringCollection(); String[] strArr = new String[] { "A", "B", "C", "D", "E", "F", "G", "H" }; Console.WriteLine("StringCollection elements..."); foreach (string str in strArr) { Console.WriteLine(str); } strCol.AddRange(strArr); Console.WriteLine("Element at 5th index = "+strCol[5]); Console.WriteLine("Count of strings ... Read More

104 Views
To get an ICollection containing the values in the Hashtable, the code is as follows −Example Live Demousing System; using System.Collections; public class Demo { public static void Main() { Hashtable hash = new Hashtable(); hash.Add("A", "Electronics"); hash.Add("B", "Appliances"); hash.Add("C", "Pet Supplies"); hash.Add("D", "Books"); hash.Add("E", "Toys"); hash.Add("F", "Footwear"); hash.Add("G", "Clothing"); ICollection col = hash.Keys; foreach(string str in col) Console.WriteLine(str + ": " + hash[str]); } }OutputThis ... Read More

172 Views
To get an ICollection containing the keys in the Hashtable, the code is as follows −Example Live Demousing System; using System.Collections; public class Demo { public static void Main() { Hashtable hash = new Hashtable(); hash.Add("A", "Electronics"); hash.Add("B", "Appliances"); hash.Add("C", "Pet Supplies"); hash.Add("D", "Books"); hash.Add("E", "Toys"); hash.Add("F", "Footwear"); hash.Add("G", "Clothing"); ICollection col = hash.Keys; foreach(string str in col) Console.WriteLine(str + ": " + hash[str]); } }OutputThis ... Read More

188 Views
To get value of the bit at a specific position in BitArray, the code is as follows −Example Live Demousing System; using System.Collections; public class Demo { public static void Main() { BitArray arr1 = new BitArray(2); BitArray arr2 = new BitArray(2); arr1[0] = false; arr1[1] = true; Console.WriteLine("BitArray1 length = "+arr1.Length); Console.WriteLine("BitArray1 first element = "+arr1.Get(0)); arr2[0] = false; arr2[1] = true; Console.WriteLine("BitArray2 length = "+arr2.Length); Console.WriteLine("Elements in BitArray2..."); ... Read More

169 Views
To get or set the value associated with specified key in Hashtable, the code is as follows −Example Live Demousing System; using System.Collections; public class Demo { public static void Main() { Hashtable hash = new Hashtable(); hash.Add("1", "AB"); hash.Add("2", "BC"); hash.Add("3", "DE"); hash.Add("4", "EF"); hash.Add("5", "GH"); hash.Add("6", "IJ"); hash.Add("7", "KL"); hash.Add("8", "MN"); hash.Add("9", "OP"); hash.Add("10", "QR"); Console.WriteLine("Value at key 3 = "+hash["3"]); ... Read More

102 Views
To get or set the number of elements that the ArrayList can contain, the code is as follows −Example Live Demousing System; using System.Collections; public class Demo { public static void Main() { ArrayList arrList = new ArrayList(); arrList.Add(25); arrList.Add(50); arrList.Add(75); arrList.Add(100); arrList.Add(125); arrList.Add(150); arrList.Add(175); arrList.Add(200); arrList.Add(225); arrList.Add(250); Console.WriteLine("Elements in ArrayList..."); foreach(int i in arrList) { Console.WriteLine(i); ... Read More