Remove Element from Specified Index of List in C#

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

283 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

Fix MySQL Error 1064 (42000)

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

4K+ Views

This error may occur if you have used an incorrect syntax. Let’s say the following is the create table statement −mysql> create table DemoTable1492    -> (    -> timestamp TIMESTAMP,    -> event int,    -> ); 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 ')' at line 5You need to remove extra comma above after the event column to fix. Let us first create a −mysql> create table DemoTable1492    -> (    -> timestamp TIMESTAMP,   ... Read More

Play User Modified Beep Sound Through Console in C#

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

351 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

Store PayPal Decimal Amount in MySQL Database

AmitDiwan
Updated on 11-Dec-2019 05:27:28

183 Views

In order to store PayPal decimal amount in the MySQL database, you can use DECIMAL(10, 2). Let us first create a table −mysql> create table DemoTable1491    -> (    -> Amount DECIMAL(10, 2)    -> ); Query OK, 0 rows affected (0.66 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1491 values(987664.50); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable1491 values(18783874.90); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable1491 values(35363738.50); Query OK, 1 row affected (0.15 sec)Display all records from the table using select statement −mysql> select * from ... Read More

Get Hashcode of a Tuple in C#

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

195 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

Find Average Price from Duplicate Product IDs in MySQL

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

430 Views

For this, use AVG() for average and GROUP BY to group records of duplicate column (Product Id). Let us first create a table −mysql> create table DemoTable1490    -> (    -> ProductId varchar(20),    -> ProductPrice int    -> ); Query OK, 0 rows affected (0.43 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1490 values('PRODUCT_100', 700); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable1490 values('PRODUCT_200', 500); Query OK, 1 row affected (0.31 sec) mysql> insert into DemoTable1490 values('PRODUCT_200', 1000); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable1490 values('PRODUCT_100', ... Read More

Create StringCollection in C#

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

141 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

Get Sum of Column with Conditions in MySQL

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

362 Views

Let us first create a table −mysql> create table DemoTable1489    -> (    -> ProductId int,    -> ProductPrice int    -> ); Query OK, 0 rows affected (0.49 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1489 values(100, 900); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable1489 values(115, 1000); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable1489 values(119, 2100); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable1489 values(125, 2100); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable1489 values(128, 2900); Query OK, 1 ... Read More

Using EXPLAIN Keyword in MySQL

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

415 Views

MySQL EXPLAIN gives a query execution plan. EXPLAIN can be used in the beginning with SELECT, INSERT, DELETE, REPLACE, and UPDATE.To avoid the complete table scan in database, you need to use index. Let us first create a table −mysql> create table DemoTable1488    -> (    -> StudentId int,    -> StudentName varchar(20),    -> StudentAge int    -> ); Query OK, 0 rows affected (2.18 sec)Here is the query to create index −mysql> create index student_id_index on DemoTable1488(StudentId); Query OK, 0 rows affected (0.90 sec) Records: 0  Duplicates: 0  Warnings: 0insert into DemoTable1488 valueInsert some records in the ... Read More

Create a Shallow Copy of SortedList Object in C#

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

238 Views

To create a shallow copy of SortedList object, the code is as follows −Example Live Demousing System; using System.Collections; public class Demo {    public static void Main(String[] args){       SortedList list = new SortedList();       list.Add("A", "Jacob");       list.Add("B", "Sam");       list.Add("C", "Tom");       list.Add("D", "John");       list.Add("E", "Tim");       list.Add("F", "Mark");       list.Add("G", "Gary");       list.Add("H", "Nathan");       list.Add("I", "Shaun");       list.Add("J", "David");       Console.WriteLine("SortedList elements...");       foreach(DictionaryEntry d in list){     ... Read More

Advertisements