Programming Articles - Page 2267 of 3366

How to get Seventh Element of the Tuple in C#?

AmitDiwan
Updated on 05-Dec-2019 12:06:35

117 Views

To get seventh element of the Tuple, the code is as follows −Example Live Demousing System; public class Demo {    public static void Main(String[] args) {       var tuple1 = Tuple.Create(75, 200, 500, 700, 100, 1200, 1500);       var tuple2 = Tuple.Create(75, 200, 500, 700, 100, 1200, 1500);       Console.WriteLine("Is Tuple1 equal to Tuple2? = "+tuple1.Equals(tuple2));       Console.WriteLine("HashCode of Tuple1 = "+tuple1.GetHashCode());       Console.WriteLine("HashCode of Tuple2 = "+tuple2.GetHashCode());       Console.WriteLine("Tuple1 Item 1st = "+tuple1.Item1);       Console.WriteLine("Tuple2 Item 1st = "+tuple2.Item1);       Console.WriteLine("Tuple1 Item 2nd ... Read More

Remove all elements from the Hashtable in C#

AmitDiwan
Updated on 05-Dec-2019 12:03:24

212 Views

To remove all elements from the Hashtable, the code is as follows −Example Live Demousing System; using System.Collections; public class Demo {    public static void Main() {       Hashtable hash = new Hashtable(10);       hash.Add("1", "A");       hash.Add("2", "B");       hash.Add("3", "C");       hash.Add("4", "D");       hash.Add("5", "E");       hash.Add("6", "F");       hash.Add("7", "G");       hash.Add("8", "H");       hash.Add("9", "I");       hash.Add("10", "J");       Console.WriteLine("Hashtable Key and Value pairs...");       foreach(DictionaryEntry entry in hash) ... Read More

Remove all elements from the Collection in C#

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

432 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

280 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

154 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

93 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

243 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

192 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

222 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

189 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

Advertisements