Found 26504 Articles for Server Side Programming

Remove the entry at specified index from OrderedDictionary in C#

AmitDiwan
Updated on 05-Dec-2019 12:43:34

100 Views

To remove the entry at specified index from OrdererdDictionary, the code is as follows −Example Live Demousing System; using System.Collections; using System.Collections.Specialized; public class Demo {    public static void Main() {       OrderedDictionary dict = new OrderedDictionary();       dict.Add("A", "Books");       dict.Add("B", "Electronics");       dict.Add("C", "Smart Wearables");       dict.Add("D", "Pet Supplies");       dict.Add("E", "Clothing");       dict.Add("F", "Footwear");       Console.WriteLine("OrderedDictionary elements...");       foreach(DictionaryEntry d in dict) {          Console.WriteLine(d.Key + " " + d.Value);       }     ... Read More

Check if two SortedList objects are equal in C#

AmitDiwan
Updated on 05-Dec-2019 12:39:56

129 Views

To check if two SortedList objects are equal, 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...");       foreach(DictionaryEntry ... Read More

Check if two OrderedDictionary objects are equal in C#

AmitDiwan
Updated on 05-Dec-2019 12:34:02

116 Views

To check if two OrderedDictionary objects are equal, 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

Remove the element with the specified key from a SortedList in C#

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

261 Views

To remove the element with the specified key from 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 ... Read More

Remove the element at the specified index of the ArrayList in C#

AmitDiwan
Updated on 05-Dec-2019 12:26:06

156 Views

To remove the element at the specified index of the ArrayList, 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);       } ... Read More

Get the number of strings in StringCollection in C#

AmitDiwan
Updated on 05-Dec-2019 12:18:59

86 Views

To get the number of strings in StringCollection, the code is as follows −Example Live Demousing System; using System.Collections.Specialized; public class Demo {    public static void Main() {       StringCollection strCol = new StringCollection();       String[] strArr = new String[] { "A", "B", "C", "D", "E", "F", "G", "H" };       Console.WriteLine("StringCollection elements...");       foreach (string str in strArr) {          Console.WriteLine(str);       }       strCol.AddRange(strArr);       Console.WriteLine("Element at 5th index = "+strCol[5]);       Console.WriteLine("Count of strings in StringCollection = " ... Read More

Get or set the value associated with the specified key in StringDictionary in C#

AmitDiwan
Updated on 05-Dec-2019 12:14:47

98 Views

To get or set the value associated with specified key in StringDictionary, the code is as follows −Example Live Demousing System; using System.Collections.Specialized; public class Demo {    public static void Main() {       StringDictionary strDict = new StringDictionary ();       strDict.Add("A", "Books");       strDict.Add("B", "Electronics");       strDict.Add("C", "Appliances");       strDict.Add("D", "Pet Supplies");       strDict.Add("E", "Clothing");       strDict.Add("F", "Footwear");       Console.WriteLine("Value associated with key D = "+strDict["D"]);       Console.WriteLine("Value associated with key F = "+strDict["F"]);    } }OutputThis will produce the following output ... Read More

Remove from the specified index of the StringCollection in C#

AmitDiwan
Updated on 05-Dec-2019 12:10:53

139 Views

To remove from the specified index of 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("Total number of elements = "+stringCol.Count);       stringCol.RemoveAt(3);       Console.WriteLine("Total number of elements ... Read More

How to get Seventh Element of the Tuple in C#?

AmitDiwan
Updated on 05-Dec-2019 12:06:35

108 Views

To get seventh element of the Tuple, the code is as follows −Example Live Demousing System; public class Demo {    public static void Main(String[] args) {       var tuple1 = Tuple.Create(75, 200, 500, 700, 100, 1200, 1500);       var tuple2 = Tuple.Create(75, 200, 500, 700, 100, 1200, 1500);       Console.WriteLine("Is Tuple1 equal to Tuple2? = "+tuple1.Equals(tuple2));       Console.WriteLine("HashCode of Tuple1 = "+tuple1.GetHashCode());       Console.WriteLine("HashCode of Tuple2 = "+tuple2.GetHashCode());       Console.WriteLine("Tuple1 Item 1st = "+tuple1.Item1);       Console.WriteLine("Tuple2 Item 1st = "+tuple2.Item1);       Console.WriteLine("Tuple1 Item 2nd ... Read More

Remove all elements from the Hashtable in C#

AmitDiwan
Updated on 05-Dec-2019 12:03:24

206 Views

To remove all elements from 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(10);       hash.Add("1", "A");       hash.Add("2", "B");       hash.Add("3", "C");       hash.Add("4", "D");       hash.Add("5", "E");       hash.Add("6", "F");       hash.Add("7", "G");       hash.Add("8", "H");       hash.Add("9", "I");       hash.Add("10", "J");       Console.WriteLine("Hashtable Key and Value pairs...");       foreach(DictionaryEntry entry in hash) ... Read More

Advertisements