Found 26504 Articles for Server Side Programming

Add key and value into OrderedDictionary collection in C#

AmitDiwan
Updated on 05-Dec-2019 13:24:33

176 Views

To add key and value into OrderedDictionary collection, the code is as follows −Example Live Demousing System; using System.Collections; using System.Collections.Specialized; public class Demo {    public static void Main() {       OrderedDictionary dict1 = new OrderedDictionary();       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("OrderedDictionary1 elements...");       foreach(DictionaryEntry d in dict1) {          Console.WriteLine(d.Key + " " + d.Value);       }       ... Read More

Add element to SortedSet in C#

AmitDiwan
Updated on 05-Dec-2019 13:20:35

165 Views

To add element to 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(100);       set1.Add(200);       set1.Add(300);       set1.Add(400);       Console.WriteLine("Elements in SortedSet...");       foreach (int res in set1) {          Console.WriteLine(res);       }       Console.WriteLine("Does the SortedSet contains the element 500? = "+set1.Contains(500));    } }OutputThis will produce the following output −Elements in SortedSet... 100 200 300 400 Does the SortedSet contains the element 500? = FalseExampleLet us ... Read More

Getting the key at the specified index of a SortedList object in C#

AmitDiwan
Updated on 05-Dec-2019 13:18:55

109 Views

To get the key at the specified index 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

Getting the index of the specified key in a SortedList object in C#

AmitDiwan
Updated on 05-Dec-2019 13:13:21

290 Views

To get index of the specified key in 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("One", "Finance");       list.Add("Two", "Marketing");       list.Add("Three", "Sales");       list.Add("Four", "Purchase");       list.Add("Five", "Operations");       list.Add("Six", "IT");       Console.WriteLine("SortedList elements...");       foreach(DictionaryEntry d in list) {          Console.WriteLine(d.Key + " " + d.Value);       }       ... Read More

Getting index of the specified value in a SortedList object in C#

AmitDiwan
Updated on 05-Dec-2019 13:09:37

89 Views

To get index of the specified value in 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

Removing the specified key entry from HybridDictionary in C#

AmitDiwan
Updated on 05-Dec-2019 13:05:42

139 Views

To remove the specified key entry from HybridDcitionary, 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);       }       ... Read More

Remove the first occurrence from the StringCollection in C#

AmitDiwan
Updated on 05-Dec-2019 13:00:00

113 Views

To remove the first occurrence from the StringCollection, the code is as follows −Example Live Demousing System; using System.Collections.Specialized; public class Demo {    public static void Main() {       StringCollection stringCol = new StringCollection();       String[] arr = new String[] { "100", "200", "100", "400", "500" };       Console.WriteLine("Array elements...");       foreach (string res in arr) {          Console.WriteLine(res);       }       stringCol.AddRange(arr);       Console.WriteLine("Total number of elements = "+stringCol.Count);       stringCol.Remove("100");       Console.WriteLine("Total number of elements now = ... Read More

Check if the StringCollection is read-only in C#

AmitDiwan
Updated on 05-Dec-2019 12:55:55

114 Views

To check if the StringCollection is read-only, the code is as follows −Example Live Demousing System; using System.Collections.Specialized; public class Demo {    public static void Main() {       StringCollection stringCol = new StringCollection();       String[] arr = new String[] { "100", "200", "300", "400", "500" };       Console.WriteLine("Array elements...");       foreach (string res in arr) {          Console.WriteLine(res);       }       stringCol.AddRange(arr);       Console.WriteLine("Is the StringCollection read-only? = "+stringCol.IsReadOnly);       Console.WriteLine("Does the specified string is in the StringCollection? = "+stringCol.Contains("800"));   ... Read More

Check if the specified string is in the StringCollection in C#

AmitDiwan
Updated on 05-Dec-2019 12:52:23

86 Views

To check if the specified string is in the StringCollection, the code is as follows −Example Live Demousing System; using System.Collections.Specialized; public class Demo {    public static void Main() {       StringCollection stringCol = new StringCollection();       String[] arr = new String[] { "100", "200", "300", "400", "500" };       Console.WriteLine("Array elements...");       foreach (string res in arr) {          Console.WriteLine(res);       }       stringCol.AddRange(arr);       Console.WriteLine("Does the specified string is in the StringCollection? = "+stringCol.Contains("800"));    } }OutputThis will produce the following ... Read More

Remove the entry with specified key from ListDictionary in C#

AmitDiwan
Updated on 05-Dec-2019 12:48:41

101 Views

To remove the entry with specified key from ListDictionary, 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

Advertisements