Found 26504 Articles for Server Side Programming

Get the last node of the LinkedList in C#

AmitDiwan
Updated on 06-Dec-2019 06:03:45

298 Views

To get the last node of 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);       Console.WriteLine("Last Node = "+list.Last.Value);   ... Read More

Get an ICollection containing the values in HybridDictionary in C#

AmitDiwan
Updated on 06-Dec-2019 05:59:45

123 Views

To get an ICollection containing the values in HybridDictionary, the code is as follows −Example Live Demousing System; using System.Collections.Specialized; public class Demo {    public static void Main(){       HybridDictionary dict = new HybridDictionary();       dict.Add("One", "Katie");       dict.Add("Two", "Andy");       dict.Add("Three", "Gary");       dict.Add("Four", "Mark");       dict.Add("Five", "Marie");       dict.Add("Six", "Sam");       dict.Add("Seven", "Harry");       dict.Add("Eight", "Kevin");       dict.Add("Nine", "Ryan");       String[] strArr = new String[dict.Count];       dict.Values.CopyTo(strArr, 0);       for (int i ... Read More

Get an ICollection containing the keys in ListDictionary in C#

AmitDiwan
Updated on 06-Dec-2019 05:53:13

103 Views

To get an ICollection containing the keys in 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 listDict = new ListDictionary();       listDict.Add("1", "Laptop");       listDict.Add("2", "Tablet");       listDict.Add("3", "Desktop");       listDict.Add("4", "Speaker");       listDict.Add("5", "Earphone");       listDict.Add("6", "Headphone");       ICollection col = listDict.Keys;       foreach(String s in col){          Console.WriteLine(s);       }    } }OutputThis will produce the following output −1 ... Read More

Removing the node at the start of the LinkedList in C#

AmitDiwan
Updated on 02-May-2020 08:18:24

97 Views

To remove the node at the start of 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("One");       list.AddLast("Two");       list.AddLast("Three");       list.AddLast("Three");       list.AddLast("Three");       list.AddLast("Four");       Console.WriteLine("Count of nodes = " + list.Count);       Console.WriteLine("Elements in LinkedList... (Enumerator iterating through LinkedList)");       LinkedList.Enumerator demoEnum = list.GetEnumerator();       while (demoEnum.MoveNext()) {          string res ... Read More

Get the number of key/value pairs in the StringDictionary in C#

AmitDiwan
Updated on 06-Dec-2019 05:46:05

113 Views

To get the number of key/value pairs in the StringDictionary, the code is as follows −Example Live Demousing System; using System.Collections; using System.Collections.Specialized; public class Demo {    public static void Main(){       StringDictionary strDict = new StringDictionary();       strDict.Add("1", "One");       strDict.Add("2", "Two");       strDict.Add("3", "Three");       strDict.Add("4", "Four");       Console.WriteLine("StringDictionary key-value pairs...");       IEnumerator demoEnum = strDict.GetEnumerator();       DictionaryEntry d;       while (demoEnum.MoveNext()) {          d = (DictionaryEntry)demoEnum.Current;          Console.WriteLine("Key = " + d.Key + ... Read More

Get the number of key/value pairs contained in ListDictionary in C#

AmitDiwan
Updated on 06-Dec-2019 05:41:41

116 Views

To get the number of key/value pairs contained in 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);       }       ListDictionary ... Read More

Removing first occurrence of specified value from LinkedList in C#

AmitDiwan
Updated on 06-Dec-2019 05:37:47

294 Views

To remove the first occurrence of specified value from 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("A");       list.AddLast("E");       list.AddLast("F");       list.AddLast("A");       list.AddLast("H");       list.AddLast("A");       list.AddLast("j");       Console.WriteLine("Count of nodes = " + list.Count);       Console.WriteLine("Elements in LinkedList... (Enumerator iterating through LinkedList)");       ... Read More

Removing first occurrence of object from Collection in C#

AmitDiwan
Updated on 06-Dec-2019 05:32:14

120 Views

To remove the first occurrence of the object from Collection, 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("Andy");       col.Add("Kevin");       col.Add("John");       col.Add("Nathan");       col.Add("Nathan");       col.Add("Katie");       col.Add("Barry");       col.Add("Nathan");       col.Add("Mark");       Console.WriteLine("Count of elements = "+ col.Count);       Console.WriteLine("Iterating through the collection...");       var enumerator = col.GetEnumerator();       while ... Read More

Remove a range of elements from the List in C#

AmitDiwan
Updated on 06-Dec-2019 05:27:45

464 Views

To remove a range of elements from the List, 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

Remove the specified element from a HashSet in C#

AmitDiwan
Updated on 06-Dec-2019 05:23:44

416 Views

To remove the specified element from a HashSet, the code is as follows −Example Live Demousing System; using System.Collections.Generic; public class Demo {    public static void Main(){       HashSet set1 = new HashSet();       set1.Add("AB");       set1.Add("CD");       set1.Add("EF");       set1.Add("AB");       set1.Add("IJ");       set1.Add("KL");       set1.Add("EF");       set1.Add("OP");       Console.WriteLine("Elements in HashSet1");       foreach(string val in set1){          Console.WriteLine(val);       }       HashSet set2 = new HashSet();       ... Read More

Advertisements