Found 26504 Articles for Server Side Programming

Creating a synchronized wrapper for the ArrayList in C#

AmitDiwan
Updated on 06-Dec-2019 11:29:24

139 Views

To create a synchronized wrapper for the 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("AB");       arrList.Add("CD");       arrList.Add("EF");       arrList.Add("GH");       arrList.Add("IJ");       arrList.Add("KL");       Console.WriteLine("ArrayList elements...");       foreach(string str in arrList) {          Console.WriteLine(str);       }       Console.WriteLine("ArrayList is synchronized? = "+arrList.IsSynchronized);    } }OutputThis will produce the following output −ArrayList elements... AB ... Read More

Check if the ArrayList has a fixed size in C#

AmitDiwan
Updated on 06-Dec-2019 11:26:13

182 Views

To check if the ArrayList has a fixed size, the code is as follows −Example Live Demousing System; using System.Collections; public class Demo {    public static void Main(String[] args) {       ArrayList list1 = new ArrayList();       list1.Add("One");       list1.Add("Two");       list1.Add("Three");       list1.Add("Four");       list1.Add("Five");       Console.WriteLine("Elements in ArrayList...");       foreach (string res in list1) {          Console.WriteLine(res);       }       ArrayList list = ArrayList.Synchronized(list1);       Console.WriteLine("Is ArrayList synchronized? = "+list.IsSynchronized);       ... Read More

Check if ArrayList is Synchronized (thread safe) in C#

AmitDiwan
Updated on 06-Dec-2019 11:24:52

304 Views

To check if ArrayList is synchronized, the code is as follows −Example Live Demousing System; using System.Collections; public class Demo {    public static void Main(String[] args) {       ArrayList list1 = new ArrayList();       list1.Add("A");       list1.Add("B");       list1.Add("C");       list1.Add("D");       list1.Add("E");       list1.Add("F");       list1.Add("G");       list1.Add("H");       list1.Add("I");       Console.WriteLine("Elements in ArrayList1...");       foreach (string res in list1) {          Console.WriteLine(res);       }       ArrayList list2 ... Read More

Check if StringDictionary is synchronized in C#

AmitDiwan
Updated on 06-Dec-2019 11:13:40

123 Views

To check if StringDictionary is synchronized, 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 de in strDict1) {          Console.WriteLine(de.Key + " " + de.Value);       }     ... Read More

Check if a SortedList object is synchronized in C#

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

156 Views

To check if a SortedList object is synchronized, 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: ... Read More

Check if ListDictionary has a fixed size in C#

AmitDiwan
Updated on 06-Dec-2019 10:52:15

198 Views

To check if ListDictionary has a fixed size, the code is as follows −Example Live Demousing System; using System.Collections; using System.Collections.Specialized; public class Demo {    public static void Main() {       ListDictionary dict1 = new ListDictionary();       dict1.Add("A", "Books");       dict1.Add("B", "Electronics");       dict1.Add("C", "Smart Wearables");       dict1.Add("D", "Pet Supplies");       dict1.Add("E", "Clothing");       dict1.Add("F", "Footwear");       Console.WriteLine("ListDictionary1 elements...");       foreach(DictionaryEntry d in dict1) {          Console.WriteLine(d.Key + " " + d.Value);       }       ... Read More

Check if ListDictionary contains a specific key in C#

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

123 Views

To check if ListDictionary contains a specific key, the code is as follows −Example Live Demousing System; using System.Collections; using System.Collections.Specialized; public class Demo {    public static void Main() {       ListDictionary dict1 = new ListDictionary();       dict1.Add("A", "Books");       dict1.Add("B", "Electronics");       dict1.Add("C", "Smart Wearables");       dict1.Add("D", "Pet Supplies");       dict1.Add("E", "Clothing");       dict1.Add("F", "Footwear");       Console.WriteLine("ListDictionary1 elements...");       foreach(DictionaryEntry d in dict1) {          Console.WriteLine(d.Key + " " + d.Value);       }     ... Read More

Getting an enumerator that iterates through HashSet in C#

AmitDiwan
Updated on 06-Dec-2019 10:39:43

389 Views

To get an enumerator that iterates through HashSet, the code is as follows −Example Live Demousing System; using System.Collections.Generic; public class Demo {    public static void Main(String[] args) {       HashSet set1 = new HashSet();       set1.Add("A");       set1.Add("B");       set1.Add("C");       set1.Add("D");       set1.Add("E");       set1.Add("F");       set1.Add("G");       set1.Add("H");       Console.WriteLine("Elements in HashSet1...");       foreach (string res in set1) {          Console.WriteLine(res);       }       HashSet set2 = new ... Read More

Get the number of nodes contained in LinkedList in C#

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

266 Views

To get the number of nodes contained in 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();   ... Read More

Check if HybridDictionary has fixed size in C#

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

120 Views

To check if HybridDictionary has fixed size, the code is as follows −Example Live Demousing System; using System.Collections; using System.Collections.Specialized; public class Demo {    public static void Main() {       HybridDictionary dict1 = new HybridDictionary();       dict1.Add("A", "Books");       dict1.Add("B", "Electronics");       dict1.Add("C", "Smart Wearables");       dict1.Add("D", "Pet Supplies");       dict1.Add("E", "Clothing");       dict1.Add("F", "Footwear");       Console.WriteLine("HybridDictionary1 elements...");       foreach(DictionaryEntry d in dict1) {          Console.WriteLine(d.Key + " " + d.Value);       }       Console.WriteLine("Is ... Read More

Advertisements