
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

253 Views
The Queue.CopyTo() method in C# is used to copy the Queue elements to an existing one-dimensional Array, starting at the specified array index.SyntaxThe syntax is as follows −public virtual void CopyTo (Array arr, int index);Above, the parameter arr is the one-dimensional Array that is the destination of the elements copied from Queue. The index parameter is the zero-based index in array at which copying begins.ExampleLet us now see an example − Live Demousing System; using System.Collections.Generic; public class Demo { public static void Main() { Queue queue = new Queue(); queue.Enqueue(100); ... Read More

160 Views
To check if a SortedList object contains a specific value, the code is as follows −Example Live Demousing System; using System.Collections; public class Demo { public static void Main(){ SortedList list = new SortedList(); list.Add("1", "One"); list.Add("2", "Two"); list.Add("3", "Three"); list.Add("4", "Four"); list.Add("5", "Five"); list.Add("6", "Six"); list.Add("7", "Seven"); list.Add("8", "Eight"); Console.WriteLine("Key and Value of SortedList...."); foreach(DictionaryEntry k in list ) Console.WriteLine("Key: {0}, Value: {1}", ... Read More

559 Views
To get an enumerator that iterates through 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"); list2.Add("UK"); ... Read More

385 Views
To get the first node of the LinkedList, the code is as follows −Example Live Demousing System; using System.Collections.Generic; public class Demo { public static void Main(){ LinkedList list = new LinkedList(); list.AddLast("A"); list.AddLast("B"); list.AddLast("C"); list.AddLast("D"); list.AddLast("E"); list.AddLast("F"); list.AddLast("G"); list.AddLast("H"); list.AddLast("I"); list.AddLast("J"); Console.WriteLine("Count of nodes = " + list.Count); Console.WriteLine("First Node = "+list.First.Value); list.Clear(); Console.WriteLine("Count ... Read More

533 Views
To get an ICollection containing the values in 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("1", "One"); dict.Add("2", "Two"); dict.Add("3", "Three"); dict.Add("4", "Four"); dict.Add("5", "Five"); dict.Add("6", "Six"); dict.Add("7", "Seven"); dict.Add("8", "Eight"); ICollection col = dict.Values; String[] strVal = new String[dict.Count]; col.CopyTo(strVal, 0); ... Read More

221 Views
To check if a Hashtable is equal to another Hashtable, the code is as follows −Example Live Demousing System; using System.Collections; public class Demo { public static void Main(){ Hashtable hash1 = new Hashtable(); hash1.Add("1", "Kevin"); hash1.Add("2", "Steve"); hash1.Add("3", "Tim"); hash1.Add("4", "Gary"); hash1.Add("5", "Kevin"); hash1.Add("6", "Steve"); hash1.Add("7", "Tom"); hash1.Add("8", "Stephen"); Console.WriteLine("HashSet1..."); ICollection key = hash1.Keys; foreach (string k in key) { ... Read More

126 Views
To check if a HashSet is a subset 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("EF"); set1.Add("OP"); Console.WriteLine("Elements in HashSet1"); foreach(string val in set1){ Console.WriteLine(val); } HashSet set2 = new HashSet(); set2.Add("KL"); set2.Add("MN"); set2.Add("OP"); set2.Add("QR"); Console.WriteLine("Elements in HashSet2"); ... Read More

355 Views
To check if two BitArray objects are equal, 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("Elements in BitArray1..."); foreach (bool res in arr1){ Console.WriteLine(res); } arr2[0] = false; arr2[1] = true; Console.WriteLine("Elements in BitArray2..."); foreach ... Read More

137 Views
To get a collection of keys in the StringDictionary, the code is as follows −Example Live Demousing System; using System.Collections; using System.Collections.Specialized; public class Demo { public static void Main(){ StringDictionary strDict1 = new StringDictionary(); strDict1.Add("U", "Electronics"); strDict1.Add("V", "Toys"); strDict1.Add("W", "Books"); strDict1.Add("X", "Accessories"); Console.WriteLine("StringDictionary1 elements..."); foreach(DictionaryEntry d in strDict1){ Console.WriteLine(d.Key + " " + d.Value); } Console.WriteLine("Does StringDictionary1 has key G? "+strDict1.ContainsKey("G")); StringDictionary strDict2 = new ... Read More

139 Views
To check if the StringDictionary contains a specific value, the code is as follows −Example Live Demousing System; using System.Collections; using System.Collections.Specialized; public class Demo { public static void Main(){ StringDictionary strDict1 = new StringDictionary(); strDict1.Add("A", "John"); strDict1.Add("B", "Andy"); strDict1.Add("C", "Tim"); strDict1.Add("D", "Ryan"); strDict1.Add("E", "Kevin"); strDict1.Add("F", "Katie"); strDict1.Add("G", "Brad"); Console.WriteLine("StringDictionary1 elements..."); foreach(DictionaryEntry d in strDict1){ Console.WriteLine(d.Key + " " + d.Value); } ... Read More