- 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)
139 Views
To copy the Hashtable elements to an Array Instance, 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", "CD"); hash.Add("3", "EF"); hash.Add("4", "GH"); hash.Add("5", "IJ"); Console.WriteLine("Hashtable Key and Value pairs..."); foreach(DictionaryEntry entry in hash){ Console.WriteLine("{0} and {1} ", entry.Key, entry.Value); } Console.WriteLine("Copied to Array Instance..."); DictionaryEntry[] ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
88 Views
To get a subset in a SortedSet, the code is as follows −Example Live Demousing System; using System.Collections.Generic; public class Demo { public static void Main(){ SortedSet set1 = new SortedSet(); set1.Add("AB"); set1.Add("BC"); set1.Add("CD"); set1.Add("EF"); Console.WriteLine("Elements in SortedSet1..."); foreach (string res in set1){ Console.WriteLine(res); } SortedSet set2 = new SortedSet(); set2.Add("BC"); set2.Add("CD"); set2.Add("DE"); set2.Add("EF"); ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
82 Views
To create a Stack, the code is as follows −Example Live Demousing System; using System.Collections.Generic; public class Demo { public static void Main(){ Stack stack = new Stack(); stack.Push(100); stack.Push(150); stack.Push(175); stack.Push(200); stack.Push(225); stack.Push(250); stack.Push(300); stack.Push(400); stack.Push(450); stack.Push(500); Console.WriteLine("Elements in the Stack:"); foreach(var val in stack){ Console.WriteLine(val); } Console.WriteLine("Count of elements ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
60 Views
To copy the entire ArrayList to a 1-D array starting at the specified index, 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("PQ"); list.Add("RS"); list.Add("TU"); list.Add("UV"); list.Add("WX"); list.Add("YZ"); Console.WriteLine("ArrayList elements..."); for (int i = 0; i < list.Count; i++) { Console.WriteLine(list[i]); } String[] strArr = new String[6] ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
85 Views
To copy the elements of ArrayList to a new array, the code is as follows −Example Live Demousing System; using System.Collections; public class Demo { public static void Main(){ ArrayList list = new ArrayList(10); list.Add("A"); list.Add("B"); list.Add("C"); list.Add("D"); list.Add("E"); list.Add("F"); list.Add("G"); list.Add("H"); list.Add("I"); list.Add("J"); Console.WriteLine("ArrayList elements..."); foreach(string str in list){ Console.WriteLine(str); } ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
60 Views
To create 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){ Console.WriteLine("Key = ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
83 Views
To create a shallow copy of the BitArray, the code is as follows −Example Live Demousing System; using System.Collections; public class Demo { public static void Main(){ BitArray arr1 = new BitArray(5); arr1[0] = false; arr1[1] = true; Console.WriteLine("BitArray length = "+arr1.Length); Console.WriteLine("BitArray first element = "+arr1.Get(0)); Console.WriteLine("BitArray second element = "+arr1.Get(1)); BitArray arr2 = (BitArray)arr1.Clone(); Console.WriteLine("BitArray2 length = "+arr2.Length); Console.WriteLine("BitArray2 first element = "+arr2.Get(0)); Console.WriteLine("BitArray2 second element = "+arr2.Get(1)); ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
162 Views
To copy the entire ArrayList to a one-dimensional array, 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("AB"); list.Add("BC"); list.Add("CD"); list.Add("EF"); list.Add("GH"); list.Add("IJ"); list.Add("KL"); list.Add("MN"); String[] strArr = new String[10]; Console.WriteLine("ArrayList..."); foreach(Object obj in list) Console.WriteLine("{0}", obj); list.CopyTo(strArr); Console.WriteLine("String ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
337 Views
To copy a String into another String, the code is as follows −Example Live Demousing System; public class Demo { static public void Main(){ string str1 = "Kevin"; string str2 = String.Copy(str1); Console.WriteLine("String1 = "+str1); Console.WriteLine("String2 = "+str2); } }OutputThis will produce the following output −String1 = Kevin String2 = KevinExampleLet us now see another example − Live Demousing System; public class Demo { static public void Main(){ string str1 = "Maisie"; string str2 = "Ryan"; Console.WriteLine("String1 (Before ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
415 Views
To check whether a List contains a specified element, 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