Found 26504 Articles for Server Side Programming

Get the number of key/values pairs contained in OrderedDictionary in C#

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

101 Views

To get the number of key/values pairs contained in OrderedDictionary, 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", "Home Appliances");       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

Only return fields which appear a certain number of times using MySQL DISTINCT?

AmitDiwan
Updated on 11-Dec-2019 05:49:49

72 Views

To return fields appearing a certain number of times, the syntax is as follows −select distinct yourColumnName, count(yourColumnName) from yourTableName where yourColumnName LIKE 'J%' group by yourColumnName having count(*) > 1 order by yourColumnName;Let us first create a table −mysql> create table DemoTable1500    -> (    -> Name varchar(20)    -> ); Query OK, 0 rows affected (0.86 sec)Insert some records in the table using insert command −Mysql> insert into DemoTable1500 values(‘Adam’); Query OK, 1 row affected (0.23 sec) mysql> insert into DemoTable1500 values('John'); Query OK, 1 row affected (0.09 sec) mysql> insert into DemoTable1500 values('Mike'); Query OK, 1 ... Read More

Check if HybridDictionary is Synchronized in C#

AmitDiwan
Updated on 11-Dec-2019 05:49:05

116 Views

To check if HybridDictionary is synchronized, 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 the HybridDictionary1 having ... Read More

Check if Input, Output and Error is redirected on the Console or not in C#

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

226 Views

To check if the input is redirected on the Console or not, the code is as follows −Example Live Demousing System; public class Demo{    public static void Main(string[] args){       Console.WriteLine("Input Redirected? = "+Console.IsInputRedirected);    } }OutputThis will produce the following output −Input Redirected? = FalseExampleTo check if the output is redirected on the Console or not, the code is as follows − Live Demousing System; public class Demo{    public static void Main(string[] args){       Console.WriteLine("Output Redirected? = "+Console.IsInputRedirected);    } }OutputThis will produce the following output −Output Redirected? = FalseExampleTo check if the error is ... Read More

Check if Caps Lock and Num Lock is on or off through Console in C#

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

365 Views

To check if Caps Lock is on or off through Console, the code is as follows −Example Live Demousing System; public class Demo{    public static void Main(string[] args){       Console.WriteLine("The CAPS LOCK is on or not? "+ Console.CapsLock);    } }OutputThis will produce the following output −The CAPS LOCK is on or not? FalseExampleTo check if Num Lock is on or off through Console, the code is as follows − Live Demousing System; public class Demo{    public static void Main(string[] args){       Console.WriteLine("The Num LOCK is on or not? "+ Console.NumberLock);    } }OutputThis will produce ... Read More

How to retrieve the system’s reference to the specified String in C#?

AmitDiwan
Updated on 11-Dec-2019 05:37:40

87 Views

To retrieve the system’s reference to the specified String, the code is as follows −Example Live Demousing System; public class Demo{    public static void Main(string[] args){       string str1 = "David";       string str2 = string.Intern(str1);       Console.WriteLine("String1 = "+str1);       Console.WriteLine("System reference of String1 = "+str2);    } }OutputThis will produce the following output −String1 = David System reference of String1 = DavidExampleLet us now see another example − Live Demousing System; public class Demo{    public static void Main(string[] args){       string str1 = "50";       ... Read More

How to remove element from the specified index of the List in C#?

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

249 Views

To remove the element from the specified index of 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("Ryan");       list.Add("Kevin");       list.Add("Andre");       list.Add("Tom");       list.Add("Fred");       list.Add("Jason");       list.Add("Jacob");       list.Add("David");       Console.WriteLine("Count of elements in the List = "+list.Count);       Console.WriteLine("Enumerator iterates through the list elements...");       List.Enumerator demoEnum = list.GetEnumerator();     ... Read More

How to play user modified Beep sound through Console in C#?

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

328 Views

To play user modified beep sound through Console, the code is as follows −Example Live Demousing System; public class Demo {    public static void Main(String[] args){       Console.WriteLine("Displaying standard output stream...");       Console.WriteLine("Standard Output Stream = "+Console.Out);       Console.WriteLine("Beep sound through Console");       Console.Beep();       Console.WriteLine("Beep sound through Console with frequence 1000 hertz and duration 500 milliseconds");       Console.Beep(1000, 500);    } }OutputThis will produce the following output −Displaying standard output stream... Standard Output Stream = System.IO.TextWriter+SyncTextWriter Beep sound through Console Beep sound through Console with frequence 1000 ... Read More

How to get the HashCode of the tuple in C#?

AmitDiwan
Updated on 11-Dec-2019 05:26:36

169 Views

To get the HashCode 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(150, 400, 500, 700, 100, 1200, 1500, Tuple.Create(50, 100));       var tuple2 = Tuple.Create(150, 400, 500, 700, 100, 1200, 1500, Tuple.Create(100, 200));       Console.WriteLine("Is Tuple1 equal to Tuple2? = "+tuple1.Equals(tuple2));       Console.WriteLine("HashCode of Tuple1 = "+tuple1.GetHashCode());       Console.WriteLine("HashCode of Tuple2 = "+tuple2.GetHashCode());    } }OutputThis will produce the following output −Is Tuple1 equal to Tuple2? = False HashCode of Tuple1 = ... Read More

How to create a StringCollection in C#?

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

119 Views

To create a StringCollection in C#, the code is as follows −Example Live Demousing System; using System.Collections.Specialized; public class Demo {    public static void Main(){       StringCollection strCol = new StringCollection();       String[] strArr = new String[] { "A", "B", "C", "D", "E", "F", "G", "H" };       Console.WriteLine("StringCollection elements...");       foreach (string str in strArr){          Console.WriteLine(str);       }       strCol.AddRange(strArr);       Console.WriteLine("Element at 5th index = "+strCol[5]);       Console.WriteLine("Count of strings in StringCollection = " + strCol.Count);    } ... Read More

Advertisements