Found 26504 Articles for Server Side Programming

Get an ICollection containing the keys in the Hashtable C#

AmitDiwan
Updated on 10-Dec-2019 06:40:14

173 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

Get value of the bit at a specific position in BitArray in C#

AmitDiwan
Updated on 10-Dec-2019 06:36:57

189 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

Get or Set the value associated with specified key in Hashtable in C#

AmitDiwan
Updated on 10-Dec-2019 06:33:58

172 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

Get or set the number of elements that the ArrayList can contain in C#

AmitDiwan
Updated on 10-Dec-2019 06:29:50

103 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

Getting the list of Values of a SortedList object in C#

AmitDiwan
Updated on 10-Dec-2019 06:26:14

108 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

Getting the list of keys of a SortedList object in C#

AmitDiwan
Updated on 10-Dec-2019 06:22:04

730 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

Get or set the number of elements in the BitArray in C#

AmitDiwan
Updated on 10-Dec-2019 06:17:55

116 Views

To get or set the number of elements in 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(2);       BitArray arr2 = new BitArray(2);       arr1[0] = false;       arr1[1] = true;       Console.WriteLine("BitArray1 length = "+arr1.Length);       Console.WriteLine("Elements in BitArray1...");       foreach (bool res in arr1) {          Console.WriteLine(res);       }       arr2[0] = false;       arr2[1] ... Read More

Union of SortedSet to a collection in C#

AmitDiwan
Updated on 10-Dec-2019 06:13:06

138 Views

To compute the Union of SortedSet to a Collection, 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(50);       set1.Add(100);       set1.Add(150);       Console.WriteLine("SortedSet1 elements...");       foreach(int ele in set1) {          Console.WriteLine(ele);       }       SortedSet set2 = new SortedSet();       set2.Add(100);       set2.Add(150);       set2.Add(200);       set2.Add(250);       Console.WriteLine("SortedSet2 elements..."); ... Read More

Bitwise OR operation between the elements of BitArray in C#

AmitDiwan
Updated on 10-Dec-2019 06:07:37

90 Views

Let us see how to implement Bitwise OR operation between the elements of BitArray −Example Live Demousing System; using System.Collections; public class Demo {    public static void Main() {       BitArray arr1 = new BitArray(5);       BitArray arr2 = new BitArray(5);       arr1[0] = false;       arr1[1] = false;       arr2[0] = false;       arr2[1] = true;       Console.WriteLine("BitArray1 elements...");       foreach (bool res in arr1) {          Console.WriteLine(res);       }       Console.WriteLine("BitArray2 elements...");       ... Read More

Get or set the element at the specified index in ArrayList in C#

AmitDiwan
Updated on 10-Dec-2019 06:04:38

969 Views

To get or set the element at the specified index in ArrayList, 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("Laptop");       arrList.Add("Desktop");       arrList.Add("Notebook");       arrList.Add("Ultrabook");       arrList.Add("Tablet");       arrList.Add("Headphone");       arrList.Add("Speaker");       Console.WriteLine("Elements in ArrayList...");       foreach(string str in arrList) {          Console.WriteLine(str);       }       Console.WriteLine("Element at index 5 = " ... Read More

Advertisements