Check If ListDictionary Contains a Specific Key in C#

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

135 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

Enumerator to Iterate Through HashSet in C#

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

395 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

Remove All CSS Classes Using jQuery

Ricky Barnes
Updated on 06-Dec-2019 10:33:52

5K+ Views

To remove all classes, use the removeClass() method with no parameters. This will remove all of the item's classes.ExampleYou can try to run the following code to remove all CSS classes using jQuery:Live Demo           jQuery Selector                          $(document).ready(function() {            $("#button1").click(function(){              $("p").removeClass();            });          });                              .red { color:red; }          .blue { color:blue; }                         This is first paragraph.       This is second paragraph.       Remove    

Write Comparator as a Lambda Expression in Java

raja
Updated on 06-Dec-2019 10:26:25

5K+ Views

A lambda expression is an anonymous method and doesn't execute on its own in java. Instead, it is used to implement a method defined by the functional interface. A lambda expression used with any functional interface and Comparator is a functional interface. The Comparator interface has used when sorting a collection of objects compared with each other.In the below example, we can sort the employee list by name using the Comparator interface.Exampleimport java.util.ArrayList; import java.util.Collections; import java.util.List; class Employee {    int id;    String name;    double salary;    public Employee(int id, String name, double salary) {       super();   ... Read More

Get Number of Nodes in Linked List using C#

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

273 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

128 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

Add New Node at the End of Linked List in C#

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

162 Views

To add new node or value at the end of 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");       Console.WriteLine("Count of nodes = " + list.Count);       Console.WriteLine("Elements in LinkedList...");       foreach (string res in list) {          Console.WriteLine(res);       }       ... Read More

Add Elements to the End of ArrayList in C#

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

218 Views

To add elements to the end 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 list = new ArrayList();       list.Add("Andy");       list.Add("Gary");       list.Add("Katie");       list.Add("Amy");       Console.WriteLine("Elements in ArrayList...");       foreach (string res in list) {          Console.WriteLine(res);       }       string[] strArr = { "John", "Jacob" };       list.AddRange(strArr);       Console.WriteLine("Elements in ArrayList...UPDATED");     ... Read More

Adding an Element to the List in C#

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

269 Views

To add an element to 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 list = new List();       list.Add("One");       list.Add("Two");       list.Add("Three");       list.Add("Four");       list.Add("Five");       list.Add("Six");       list.Add("Seven");       list.Add("Eight");       Console.WriteLine("Enumerator iterates through the list elements...");       List.Enumerator demoEnum = list.GetEnumerator();       while (demoEnum.MoveNext()) {          string res = demoEnum.Current;     ... Read More

Check if SortedDictionary Contains Specified Key in C#

AmitDiwan
Updated on 06-Dec-2019 10:08:09

156 Views

To check if SortedDictionary contains the specified key or not, the code is as follows −Example Live Demousing System; using System.Collections; using System.Collections.Generic; public class Demo {    public static void Main() {       SortedDictionary sortedDict = new SortedDictionary();       sortedDict.Add(100, "Mobile");       sortedDict.Add(200, "Laptop");       sortedDict.Add(300, "Desktop");       sortedDict.Add(400, "Speakers");       sortedDict.Add(500, "Headphone");       sortedDict.Add(600, "Earphone");       Console.WriteLine("SortedDictionary key-value pairs...");       IDictionaryEnumerator demoEnum = sortedDict.GetEnumerator();       while (demoEnum.MoveNext())       Console.WriteLine("Key = " + demoEnum.Key + ", Value = ... Read More

Advertisements