Samual Sam has Published 2492 Articles

How can we modify an existing MySQL event?

Samual Sam

Samual Sam

Updated on 22-Jun-2020 12:34:23

360 Views

With the help of ALTER EVENT statement, we can modify an existing MySQL event. We can change the various attributes of an event. ALTER EVENT has the following syntax −   ALTER EVENT event_name     ON SCHEDULE schedule ON COMPLETION [NOT] PRESERVE   RENAME TO new_event_name     ENABLE | ... Read More

How to make a C# program sleep for x milliseconds?

Samual Sam

Samual Sam

Updated on 22-Jun-2020 12:32:53

1K+ Views

To make a C# program sleep for x milliseconds, use the Thread.Sleep() method.To set it for 1000 milliseconds −Thread.Sleep(1000);The following is the code showing how to set a counter for the thread and set it to sleep for 1000 milliseconds on every iteration of for loop −Example Live Demousing System; using ... Read More

How to instantiate a class in C#?

Samual Sam

Samual Sam

Updated on 22-Jun-2020 12:13:46

4K+ Views

Use the new operator to instantiate a class in C#.Let’s say our class is Line. Instantiation will create a new object as shown below −Line line = new Line();Using the object, you can now call the method −line.setLength(6.0);Let us see the example −Example Live Demousing System; namespace LineApplication {   ... Read More

How to iterate efficiently through an array of integers of unknown size in C#

Samual Sam

Samual Sam

Updated on 22-Jun-2020 12:12:32

372 Views

To iterate efficiently through an array of integers of unknown size in C# is easy. Let’s see how.Firstly, set an array, but do not set the size −int[] arr = new int[] { 5, 7, 2, 4, 1 };Now, get the length and iterate through an array using for loop ... Read More

How to join or concatenate two lists in C#?

Samual Sam

Samual Sam

Updated on 22-Jun-2020 12:11:06

2K+ Views

To concatenate two lists, use AddRange() method.Set the first list −var products1 = new List < string > (); products1.Add("Belts"); products1.Add("Tshirt"); products1.Add("Trousers");Set the second list −var products2 = new List < string > (); products2.Add("Footwear"); products2.Add("Electronics");To concatenate both the lists −products1.AddRange(products2);The following is the complete code −Example Live Demousing System.Collections.Generic; using ... Read More

How to loop through all values of an enum in C#?

Samual Sam

Samual Sam

Updated on 22-Jun-2020 12:08:45

2K+ Views

To loop through all the values of enum, use the Enum.GetValues().Firstly, set an Enum −public enum Grade { A, B, C, D, E, F };Now, with foreach loop, you need to loop through Enum.GetValues(typeof(Grade)) −foreach (Grade g in Enum.GetValues(typeof(Grade))) {    Console.WriteLine(g); }Here is the complete code −Example Live Demousing System; ... Read More

How to initialize a dictionary to an empty dictionary in C#?

Samual Sam

Samual Sam

Updated on 22-Jun-2020 11:59:00

11K+ Views

To initialize a dictionary to an empty dictionary, use the Clear() method. It clears the dictionary and forms it as empty.dict.Clear();After that, use the Dictionary count property to check whether the list is empty or not −if (dict.Count == 0) {    Console.WriteLine("Dictionary is empty!"); }Let us see the complete ... Read More

How does ‘FOR EACH ROW’ work in the MySQL trigger?

Samual Sam

Samual Sam

Updated on 22-Jun-2020 11:54:52

4K+ Views

Actually ‘FOR EACH ROW’ means for each of the matched rows that get either updated or deleted. In other words, we can say that trigger is not applied to each row, it just says to execute the trigger body for each affected table row. We can illustrate this by the ... Read More

How to input multiple values from user in one line in C#?

Samual Sam

Samual Sam

Updated on 22-Jun-2020 11:40:25

2K+ Views

Use a while loop to input multiple values from the user in one line.Let’s say you need to get the elements of a matrix. Get it using Console.ReadLine() as shown below −Console.Write("Enter elements - Matrix 1 : "); for (i = 0; i < m; i++) {    for (j ... Read More

How can we convert subqueries to INNER JOIN?

Samual Sam

Samual Sam

Updated on 22-Jun-2020 10:59:14

1K+ Views

To make it understand we are using the data from the following tables −mysql> Select * from customers; +-------------+----------+ | Customer_Id | Name     | +-------------+----------+ |           1 | Rahul    | |           2 | Yashpal  | |   ... Read More

Advertisements