Found 26504 Articles for Server Side Programming

Remove all elements from the Collection in C#

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

425 Views

To remove all elements from the 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(10);       col.Add(20);       col.Add(30);       col.Add(40);       col.Add(50);       col.Add(60);       col.Add(70);       col.Add(80);       Console.WriteLine("Elements in the Collection...");       foreach(int val in col) {          Console.WriteLine(val);       }       Console.WriteLine("Does the collection has the element ... Read More

Check whether the specified Unicode character is a punctuation mark in C#

AmitDiwan
Updated on 05-Dec-2019 11:53:57

273 Views

To check whether the specified Unicode character is a punctuation mark, the code is as follow −Example Live Demousing System; public class Demo {    public static void Main() {       bool res;       char val = 'q';       Console.WriteLine("Value = "+val);       res = Char.IsPunctuation(val);       Console.WriteLine("Is the value a punctuation? = "+res);    } }OutputThis will produce the following output −Value = q Is the value a punctuation? = FalseExampleLet us see another example − Live Demousing System; public class Demo {    public static void Main() {     ... Read More

Get the hash code for the current Int64 instance in C#

AmitDiwan
Updated on 05-Dec-2019 11:51:00

143 Views

To get the hash code for the current Int64 instance, the code is as follows −Example Live Demousing System; public class Demo {    public static void Main() {       long val1 = 8768768768;       long val2 = 7889765555;       Console.WriteLine("Value1 = "+val1);       Console.WriteLine("Value2 = "+val2);       Console.WriteLine("Are they equal? = "+val1.Equals(val2));       Console.WriteLine("Value1 (HashCode) = "+val1.GetHashCode());       Console.WriteLine("Value2 (HashCode) = "+val2.GetHashCode());    } }OutputThis will produce the following output −Value1 = 8768768768 Value2 = 7889765555 Are they equal? = False Value1 (HashCode) = 178834178 Value2 (HashCode) = -700169038ExampleLet us see another example − Live Demousing System; public class Demo { ... Read More

Compare this instance is equal to a specified object or Int64 in C#

AmitDiwan
Updated on 05-Dec-2019 11:45:31

88 Views

To compare this instance is equal to a specified object or Int64, the code is as follows −Example Live Demousing System; public class Demo {    public static void Main() {       long val1 = 150;       long val2 = 240;       Console.WriteLine("Value1 = "+val1);       Console.WriteLine("Value2 = "+val2);       Console.WriteLine("Are they equal? = "+val1.Equals(val2));    } }OutputThis will produce the following output −Value1 = 150 Value2 = 240 Are they equal? = FalseExampleLet us see another example − Live Demousing System; public class Demo {    public static void Main() {       long val1 = ... Read More

Check whether the Unicode character is a lowercase letter in C#

AmitDiwan
Updated on 05-Dec-2019 11:30:32

228 Views

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

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

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

182 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

214 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

178 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

118 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

165 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

Advertisements