Create a Queue from Another Collection in C#

AmitDiwan
Updated on 16-Dec-2019 07:12:14

105 Views

To create a Queue from another collection, 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("One");       queue.Enqueue("Two");       queue.Enqueue("Three");       Console.WriteLine("Queue elements...");       foreach(string str in queue) {          Console.WriteLine(str);       }       Console.WriteLine("Array elements...");       Queue arr = new Queue(queue.ToArray());       foreach(string str in arr) {          Console.WriteLine(str);       }   ... Read More

Alternative to MySQL CASE WHEN

AmitDiwan
Updated on 16-Dec-2019 07:04:51

714 Views

Use IF() method as an alternative to CASE WHEN in MySQL. Let us first create a table −mysql> create table DemoTable1593    -> (    -> PlayerScore int    -> ); Query OK, 0 rows affected (0.44 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1593 values(78); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable1593 values(0); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable1593 values(89); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable1593 values(0); Query OK, 1 row affected (0.16 sec)Display all records from the table using ... Read More

Count Total Number of Elements in a List in C#

AmitDiwan
Updated on 16-Dec-2019 07:03:45

618 Views

To count the total number of elements in 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("One");       list.Add("Two");       list.Add("Three");       list.Add("Four");       list.Add("Five");       Console.WriteLine("Elements in List1...");       foreach (string res in list) {          Console.WriteLine(res);       }       Console.WriteLine("Count of elements in list = "+list.Count);       list.Clear();       ... Read More

Update MySQL Field if Contains NULL or 0

AmitDiwan
Updated on 16-Dec-2019 06:52:29

265 Views

For this, set conditions using MySQL IF(). Let us first create a table −mysql> create table DemoTable1592    -> (    -> StudentMarks int    -> ); Query OK, 0 rows affected (0.76 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1592 values(56); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable1592 values(NULL); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable1592 values(98); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable1592 values(0); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable1592 values(75); Query OK, 1 row affected ... Read More

Convert Varchar Time to Real Time in MySQL

AmitDiwan
Updated on 16-Dec-2019 06:51:20

489 Views

For this, you can use TIME_FORMAT(). Let us first create a table −mysql> create table DemoTable1591    -> (    -> ArrivalTime varchar(20)    -> ); Query OK, 0 rows affected (0.58 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1591 values('1620'); Query OK, 1 row affected (0.09 sec) mysql> insert into DemoTable1591 values('2345'); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable1591 values('2210'); Query OK, 1 row affected (0.12 sec)Display all records from the table using select statement −mysql> select * from DemoTable1591;This will produce the following output −+-------------+ | ArrivalTime | +-------------+ ... Read More

Insert Rows in an Empty Table to Test ABAP Code Output

Samual Sam
Updated on 16-Dec-2019 06:51:16

545 Views

You can find the option to either insert a row into a table or change the content of the table using the Table tools/Table display services

StringDictionary Class in C#

AmitDiwan
Updated on 16-Dec-2019 06:50:36

223 Views

The StringDictionay class implements a hash table with the key and the value strongly typed to be strings rather than objects.Following are the properties of the StringDictionary class −Sr.NoProperty & Description1CountGets the number of key/value pairs in the StringDictionary.2IsSynchronizedGets a value indicating whether access to the StringDictionary is synchronized (thread safe).3tem[String]Gets or sets the value associated with the specified key.4KeysGets a collection of keys in the StringDictionary..5SyncRootGets an object that can be used to synchronize access to the StringDictionary.6ValuesGets a collection of values in the StringDictionary.Following are some of the methods of the StringDictionary class −Sr.NoMethods & Description1Add(String, String)Adds an ... Read More

Combine Two MySQL Fields and Update a Third One with Result

AmitDiwan
Updated on 16-Dec-2019 06:49:03

535 Views

Following is the syntax to combine two fields in MySQL −alter table yourTableName add column yourColumnName dataType;  update yourTableName set yourAddedColumnName =concat(yourColumnName1, ' ', yourColumnName2);Let us first create a table −mysql> create table DemoTable1590    -> (    -> FirstName varchar(20),    -> LastName varchar(20)    -> ); Query OK, 0 rows affected (0.57 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1590 values('Adam', 'Smith'); Query OK, 1 row affected (0.45 sec) mysql> insert into DemoTable1590 values('John', 'Doe'); Query OK, 1 row affected (0.42 sec) mysql> insert into DemoTable1590 values('David', 'Miller'); Query OK, 1 row affected ... Read More

Create a Database with a Numeric Name in MySQL

AmitDiwan
Updated on 16-Dec-2019 06:46:28

421 Views

You cannot create database with numeric name as shown below −mysql> create database 1233;This will produce the following output −ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '1233' at line 1To create a database with numeric name, you need to use backticks around the database name −create database yourDatabaseName;Let us implement the above syntax −mysql> create database `1233`; Query OK, 1 row affected (0.20 sec)Now you can switch to the same database −mysql> use `1233`; Database changed

Get Synchronized Access to HybridDictionary in C#

AmitDiwan
Updated on 16-Dec-2019 06:45:29

117 Views

To get synchronize access to HybridDictionary, the code is as follows −Exampleusing 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 ... Read More

Advertisements