AmitDiwan has Published 10740 Articles

How to use strings in switch statement in C#

AmitDiwan

AmitDiwan

Updated on 11-Dec-2019 07:15:20

2K+ Views

A switch statement allows a variable to be tested for equality against a list of values. Each value is called a case, and the variable being switched on is checked for each switch case.ExampleHere is an example to use strings in a switch statement − Live Demousing System; public class Demo ... Read More

Get an enumerator that iterates through the StringDictionary in C#

AmitDiwan

AmitDiwan

Updated on 11-Dec-2019 07:13:32

124 Views

To get an enumerator that iterates through 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 strDict1 = new StringDictionary();       strDict1.Add("A", "John");       strDict1.Add("B", "Andy");     ... Read More

Get an enumerator that iterates through the SortedSet in C#

AmitDiwan

AmitDiwan

Updated on 11-Dec-2019 07:10:21

129 Views

To get an enumerator that iterates through the 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("AB");       set1.Add("BC");       set1.Add("CD");   ... Read More

How to create a shallow copy of ArrayList in C#?

AmitDiwan

AmitDiwan

Updated on 11-Dec-2019 07:09:00

260 Views

To create a shallow copy of ArrayList in C#, the code is as follows −Example Live Demousing System; using System.Collections; public class Demo {    public static void Main(){       ArrayList list = new ArrayList();       list.Add("One");       list.Add("Two");       list.Add("Three");     ... Read More

Check if every List element matches the predicate conditions in C#

AmitDiwan

AmitDiwan

Updated on 11-Dec-2019 07:06:51

385 Views

To check if every List element matches the predicate conditions, the code is as follows −Example Live Demousing System; using System.Collections.Generic; public class Demo {    private static bool demo(int i) {       return ((i % 10) == 0);    }    public static void Main(String[] args) {   ... Read More

How to create a ListDictionary in C#?

AmitDiwan

AmitDiwan

Updated on 11-Dec-2019 07:05:05

122 Views

To create a 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 dict = new ListDictionary();       dict.Add("1", "SUV");       dict.Add("2", "Sedan");       dict.Add("3", "Utility Vehicle");   ... Read More

Intersection of two HashSets in C#

AmitDiwan

AmitDiwan

Updated on 11-Dec-2019 07:02:09

542 Views

To find the intersection of two HashSets, 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"); ... Read More

Intersection of SortedSet with a collection in C#

AmitDiwan

AmitDiwan

Updated on 11-Dec-2019 06:58:58

165 Views

To get the intersection of SortedSet with a Collection, the code is as follow −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);     ... Read More

Insert into OrderedDictionary with key and value at specified index in C#

AmitDiwan

AmitDiwan

Updated on 11-Dec-2019 06:53:56

357 Views

To insert into OrderedDictionary with key and value at specified index, 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"); ... Read More

Insert at the specified index in StringCollection in C#

AmitDiwan

AmitDiwan

Updated on 11-Dec-2019 06:48:14

183 Views

To insert at the specified index 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();       strCol.Add("Accessories");       strCol.Add("Books");       strCol.Add("Electronics");       ... Read More

Advertisements