- 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
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
71 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
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
94 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
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
58 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
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
72 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
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
132 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
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
131 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
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
125 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
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
54 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
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
71 Views
To get the list of values 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 list = new SortedList(); list.Add("A", 1); list.Add("B ", 2); list.Add("C ", 3); list.Add("D", 4); list.Add("E", 5); list.Add("F", 6); list.Add("G", 7); list.Add("H", 8); Console.WriteLine("SortedList elements..."); foreach(DictionaryEntry d in list) { Console.WriteLine(d.Key + ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
580 Views
To get the list of keys 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