Found 2628 Articles for Csharp

Check whether the specified Unicode character is a letter or a decimal digit in C#

AmitDiwan
Updated on 05-Dec-2019 11:25:35

108 Views

To check whether the specified Unicode character is a letter or a decimal digit, the code is as follows −Example Live Demousing System; public class Demo {    public static void Main() {       bool res;       char val = '1';       Console.WriteLine("Value = "+val);       res = Char.IsLetterOrDigit(val);       Console.WriteLine("Is the value a letter or digit? = "+res);    } }OutputThis will produce the following output −Value = 1 Is the value a letter or digit? = TrueExampleLet us see another example − Live Demousing System; public class Demo {    public static void Main() {       bool res; ... Read More

Get the TypeCode for value type Char in C#

AmitDiwan
Updated on 05-Dec-2019 11:22:52

85 Views

To get the TypeCode for value type Char, the code is as follows −Example Live Demousing System; public class Demo {    public static void Main() {       char val = '5';       bool res;       Console.WriteLine("Hashcode for val = "+val.GetHashCode());       res = val.Equals('m');       Console.WriteLine("Return Value = "+res);       Console.WriteLine("Numeric Value = "+Char.GetNumericValue(val));       TypeCode type = val.GetTypeCode();       Console.WriteLine("Type = "+type);    } }OutputThis will produce the following output −Hashcode for val = 3473461 Return Value = False Numeric Value = 5 Type = CharExampleLet us see another example − Live Demousing System; public class ... Read More

Remove from the specified index of a SortedList in C#

AmitDiwan
Updated on 05-Dec-2019 11:20:22

97 Views

To remove from the specified index of 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 in sortedList) ... Read More

Remove entry with specified key from the StringDictionary in C#

AmitDiwan
Updated on 05-Dec-2019 11:14:01

63 Views

To remove entry with specified key from 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 strDict1 = new StringDictionary();       strDict1.Add("A", "John");       strDict1.Add("B", "Andy");       strDict1.Add("C", "Tim");       strDict1.Add("D", "Ryan");       strDict1.Add("E", "Kevin");       strDict1.Add("F", "Katie");       strDict1.Add("G", "Brad");       Console.WriteLine("StringDictionary1 key-value pairs...");       foreach(DictionaryEntry de in strDict1) {          Console.WriteLine(de.Key + " " + de.Value);     ... Read More

Remove entry with specified key from OrderedDictionary in C#

AmitDiwan
Updated on 05-Dec-2019 11:10:13

109 Views

To remove entry with specified key from OrdererdDictionary in C#, 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

Get the object at the beginning of the Queue – Peek Operation in C#

AmitDiwan
Updated on 05-Dec-2019 11:04:35

96 Views

To get the object at the beginning of the Queue, the code is as follows −Example Live Demousing System; using System.Collections.Generic; public class Demo {    public static void Main() {       Queue queue = new Queue();       queue.Enqueue("A");       queue.Enqueue("B");       queue.Enqueue("C");       queue.Enqueue("D");       queue.Enqueue("E");       queue.Enqueue("F");       queue.Enqueue("G");       Console.WriteLine("Count of elements = "+queue.Count);       Console.WriteLine("Element at the beginning of queue = " + queue.Peek());    } }OutputThis will produce the following output −Count of elements = 7 Element at the beginning of queue = AExampleLet us see another ... Read More

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

AmitDiwan
Updated on 05-Dec-2019 10:57:14

78 Views

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

Check if two StringDictionary objects are equal or not in C#

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

98 Views

To check if two StringDictionary objects are equal or not, the code is as follows −Example Live Demousing System; using System.Collections.Specialized; public class Demo {    public static void Main() {       StringDictionary strDict1 = new StringDictionary();       strDict1.Add("A", "John");       strDict1.Add("B", "Andy");       strDict1.Add("C", "Tim");       strDict1.Add("D", "Ryan");       strDict1.Add("E", "Kevin");       strDict1.Add("F", "Katie");       strDict1.Add("G", "Brad");       StringDictionary strDict2 = new StringDictionary();       strDict2.Add("A", "John");       strDict2.Add("B", "Andy");       strDict2.Add("C", "Tim");       strDict2.Add("D", ... Read More

Check if two StringCollection objects are equal in C#

AmitDiwan
Updated on 05-Dec-2019 10:48:15

77 Views

To check if two StringCollection objects are equal, the code is as follows −Example Live Demousing System; using System.Collections.Specialized; public class Demo {    public static void Main() {       StringCollection strCol1 = new StringCollection();       strCol1.Add("Accessories");       strCol1.Add("Books");       strCol1.Add("Electronics");       Console.WriteLine("StringCollection1 elements...");       foreach (string res in strCol1) {          Console.WriteLine(res);       }       StringCollection strCol2 = new StringCollection();       strCol2.Add("Accessories");       strCol2.Add("Books");       strCol2.Add("Electronics");       Console.WriteLine("StringCollection2 elements...");       foreach ... Read More

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

AmitDiwan
Updated on 05-Dec-2019 10:42:04

90 Views

To get or set the value associated with specified key 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 dict = new ListDictionary();       dict.Add("A", "Books");       dict.Add("B", "Electronics");       dict.Add("C", "Appliances");       dict.Add("D", "Pet Supplies");       dict.Add("E", "Clothing");       dict.Add("F", "Footwear");       Console.WriteLine("Value associated with key C = "+dict["C"]);    } }OutputThis will produce the following output −Value associated with key C = AppliancesExampleLet us see another example − Live Demousing System; using ... Read More

Advertisements