Determine the Size of an Array in C#

seetha
Updated on 22-Jun-2020 12:28:58

232 Views

Firstly, set an array −int[] arr = {6, 3, 8, 4};Now, use the Length property to get the size of the array −arr.LengthLet us see the complete code −Example Live Demousing System; namespace Demo {    public class Demo {       public static void Main(string[] args) {          int[] arr = {6, 3, 8, 4};          Console.WriteLine("Array...");          foreach (int i in arr) {             Console.Write(i + " ");          }          Console.WriteLine("Size of Array: "+arr.Length);       }    } }OutputArray... 6 3 8 4 Size of Array: 4

Create MySQL One-Time Event After Specified Time Interval

Akshaya Akki
Updated on 22-Jun-2020 12:28:53

322 Views

As we know a one-time event means the events that will be executed only once on a particular schedule. To illustrate the creation of such kind of events we are using the following example in which we are creating an event which will execute after some specified time interval −Examplemysql> CREATE EVENT testing_event5 ON SCHEDULE AT CURRENT_TIMESTAMP + INTERVAL 1 MINUTE ON COMPLETION PRESERVE DO INSERT INTO event_message(message, generated_at) Values('Hi', NOW()); Query OK, 0 rows affected (0.06 sec) mysql> Select * from event_message; +----+---------+---------------------+ | ID | MESSAGE | Generated_at        | +----+---------+---------------------+ | 1  | Hello ... Read More

Combine Values of Two or More Columns in MySQL Table

Nancy Den
Updated on 22-Jun-2020 12:28:19

181 Views

For combining the values of two or more columns of MySQL table, we can use CONCAT() string function. Basically, MySQL CONCAT() function is used to combine two or more strings.SyntaxCONCAT(String1, String2, …, StringN)Here, the arguments of CONCAT functions are the strings that need to be combined.Examplemysql> select CONCAT('Ram', 'is', 'a', 'good', 'boy') AS Remarks; +---------------+ | Remarks       | +---------------+ | Ramisagoodboy | +---------------+ 1 row in set (0.00 sec)Similarly, we can use CONCAT() function to combine the values of two or more columns. For example, suppose we have a table named ‘Student’ and we want the name ... Read More

Iterate Over a Chash Tuple

Chandu yadav
Updated on 22-Jun-2020 12:28:17

2K+ Views

Firstly, declare a tuple and add values −Tuple tuple = new Tuple(100, "Tom");With C#, to iterate over a tuple, you can go for individual elements −tuple.Item1 // first item tuple.Item2 // second item To display the complete tuple, just use: // display entire tuple Console.WriteLine(tuple);Let us see the complete code −Exampleusing System; using System.Threading; namespace Demo {    class Program {       static void Main(string[] args) {          Tuple tuple = new Tuple(100, "Tom");          if (tuple.Item1 == 100) {             Console.WriteLine(tuple.Item1);          }          if (tuple.Item2 == "Tom") {             Console.WriteLine(tuple.Item2);          }          // display entire tuple          Console.WriteLine(tuple);       }    } }

List All Substrings in a Given String Using C#

George John
Updated on 22-Jun-2020 12:27:41

691 Views

To list all the substrings, use the Substring method and loop through the length of the string.Let’s say our string is −string myStr = "pqrz";Use nested loop and get the substring in a new string −for (int i = 1; i < myStr.Length; i++) {    for (int start = 0; start

Match Values with Backslashes from MySQL Column

V Jyothi
Updated on 22-Jun-2020 12:27:40

878 Views

With the help of an RLIKE operator, we can perform such kind of matching. The only concept is about to use a number of backslashes in MySQL query. The example below will make it clearer −We have the following table having values such as ‘a\b’ and ‘a\b’.mysql> select * from backslashes; +------+-------+ | Id   | Value | +------+-------+ |    1 | 200   | |    2 | 300   | |    4 | a\b  | |    3 | a\b   | +------+-------+ 4 rows in set (0.10 sec)Now suppose if we want to match the ... Read More

Loop Through All Elements of an Array in C#

Ankith Reddy
Updated on 22-Jun-2020 12:26:59

304 Views

Firstly, set an array and initialize it −int[] arr = new int[] {34, 56, 12};To loop through all the elements of an array −for (int i = 0; i < arr.Length; i++) {    Console.WriteLine(arr[i]); }Let us see the complete code −Exampleusing System; public class Program {    public static void Main() {       int[] arr = new int[] {34, 56, 12};       // Length       Console.WriteLine("Length:" + arr.Length);       for (int i = 0; i< arr.Length; i++) {          Console.WriteLine(arr[i]);       }    } }

Fetch Alternate Even Numbered Records from MySQL Table

Sravani S
Updated on 22-Jun-2020 12:26:48

386 Views

To understand this concept we are using the data from table ‘Information’ as follows −mysql> Select * from Information; +----+---------+ | id | Name    | +----+---------+ |  1 | Gaurav  | |  2 | Ram     | |  3 | Rahul   | |  4 | Aarav   | |  5 | Aryan   | |  6 | Krishan | +----+---------+ 6 rows in set (0.00 sec)Now, the query below will fetch the alternate even-numbered records from the above table ‘Information’ −mysql> Select id,Name from information group by id having mod(id,2) = 0; +----+---------+ | id | Name    | +----+---------+ |  2 | Ram     | |  4 | Aarav   | |  6 | Krishan | +----+---------+ 3 rows in set (0.00 sec)

Traversal in Singly Linked List Using C Hash

Arjun Thakur
Updated on 22-Jun-2020 12:26:27

595 Views

Set a linkelist collection −var list = new LinkedList();Now, add elements −list.AddLast("One"); list.AddLast("Two"); list.AddLast("Four");Now, let us add new elements in the already created LinkedList −LinkedListNode node = list.Find("Four"); list.AddBefore(node, "Three"); list.AddAfter(node, "Five");Let us now see how to traverse through the nodes in a Singly Linked List −Exampleusing System; using System.Collections.Generic; public class Demo {    public static void Main(string[] args) {       var list = new LinkedList < string > ();       list.AddLast("One");       list.AddLast("Two");       list.AddLast("Four");       Console.WriteLine("Travering...");       foreach(var res in list) {   ... Read More

Delete Existing MySQL Event Permanently

Anjana
Updated on 22-Jun-2020 12:26:04

370 Views

We need to use the DROP statement to delete an existing MySQL event permanently. To illustrate it we are deleting the event named testing_event as follows −Examplemysql> DROP EVENT testing_event; Query OK, 0 rows affected (0.00 sec)

Advertisements