
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 26504 Articles for Server Side Programming

140 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

122 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

142 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

211 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

478 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

601 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

116 Views
To copy the Collection elements to an array, 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("One"); col.Add("Two"); col.Add("Three"); col.Add("Four"); col.Add("Five"); col.Add("Six"); col.Add("Seven"); col.Add("Eight"); Console.WriteLine("Collection...."); foreach(string str in col){ Console.WriteLine(str); } string[] strArr = new string[10]; col.CopyTo(strArr, 2); ... Read More

257 Views
To copy BitArray elements to an Array, the code is as follows −Example Live Demousing System; using System.Collections; public class Demo { public static void Main(){ BitArray arr = new BitArray(2); arr[0] = false; arr[1] = true; Console.WriteLine("Elements in BitArray..."); foreach (bool res in arr){ Console.WriteLine(res); } bool[] boolArr = new bool[2]; boolArr[0] = true; boolArr[1] = false; arr.CopyTo(boolArr, 0); Console.WriteLine("Array..."); ... Read More

195 Views
To copy the stack to an array, 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(10); stack.Push(20); stack.Push(30); stack.Push(40); stack.Push(50); stack.Push(60); stack.Push(70); stack.Push(80); stack.Push(90); stack.Push(100); Console.WriteLine("Displaying the stack..."); foreach(int val in stack){ Console.WriteLine(val); } int[] ... Read More

371 Views
To copy the entire LinkedList to Array, 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(100); list.AddLast(200); list.AddLast(300); int[] strArr = new int[5]; list.CopyTo(strArr, 0); foreach(int str in strArr){ Console.WriteLine(str); } } }OutputThis will produce the following output −100 200 300 0 0ExampleLet us now see another example − Live Demousing System; using System.Collections.Generic; public class ... Read More