C# Program to Iterate Over a String Array with For Loop

Chandu yadav
Updated on 22-Jun-2020 13:52:06

3K+ Views

Create a string array −string[] str = new string[] {    "Videos",    "Tutorials",    "Tools",    "InterviewQA" };Loop until the length of the array −for (int i = 0; i < str.Length; i++) {    string res = str[i];    Console.WriteLine(res); }Here is the complete code −Example Live Demousing System; public class Demo {    public static void Main() {       string[] str = new string[] {          "Videos",          "Tutorials",          "Tools",          "InterviewQA"       };           Console.WriteLine("String Array...");       for (int i = 0; i < str.Length; i++) {          string res = str[i];          Console.WriteLine(res);       }    } }OutputString Array... Videos Tutorials Tools InterviewQA

Display All Records from MySQL Table Using PHP Script

Priya Pallavi
Updated on 22-Jun-2020 13:52:00

1K+ Views

To illustrate this we are fetching all the records from a table named ‘Tutorials_tbl’ with the help of PHP script that uses mysql_query() and mysql_fetch_array() function in the following example −

Create MySQL View with a Subquery

Sharon Christine
Updated on 22-Jun-2020 13:51:28

2K+ Views

To illustrate the making of MySQL view with subquery we are using the following data from the table ‘Cars’ −mysql> select * from cars; +------+--------------+---------+ | ID   | Name         | Price   | +------+--------------+---------+ |    1 | Nexa         | 750000  | |    2 | Maruti Swift | 450000  | |    3 | BMW          | 4450000 | |    4 | VOLVO        | 2250000 | |    5 | Alto         | 250000  | |    6 | Skoda ... Read More

C# Program to Create an Empty String Array

George John
Updated on 22-Jun-2020 13:51:23

4K+ Views

To create an empty string array −string[] str = new string[] {};Above, we haven’t added elements to the array, since it is empty.Even if we will loop though the array, it won’t display anything as shown below −Example Live Demousing System; public class Demo {    public static void Main() {       string[] str = new string[] {};       Console.WriteLine("String Array elements won't get displayed since it's empty...");       for (int i = 0; i < str.Length; i++) {          string res = str[i];          Console.WriteLine(res);       }    } }OutputString Array elements won't get displayed since it's empty...

C# Program to Find the Index of a Word in a String

Ankith Reddy
Updated on 22-Jun-2020 13:50:59

602 Views

Declare and initialize an array −string[] str = new string[] {    "Cat",    "Mat",    "Rat" };Now, ue IndexOf() method to find the index of the word “Mat” −Array.IndexOf(str, "Mat");The following is the code −Example Live Demousing System; public class Demo {    public static void Main() {       string[] str = new string[] {          "Cat",          "Mat",          "Rat"       };       Console.WriteLine("Our Array =");       for (int i = 0; i < str.Length; i++) {          string res = str[i];          Console.WriteLine(res);       }       int findIndex = Array.IndexOf(str, "Mat");       Console.Write("Element Mat found at the following index: ");       Console.WriteLine(findIndex);    } }OutputOur Array = Cat Mat Rat Element Mat found at the following index: 1

Ensure Consistency of MySQL Views

Rama Giri
Updated on 22-Jun-2020 13:50:38

213 Views

In case of updateable views, it is quite possible that we update the data that is not visible through the view because we create a view to revealing only the partial data of a table. Such kind of updates makes the view inconsistent. We can ensure the consistency of views by using WITH CHECK OPTION while creating or modifying the views. Although WITH CHECK OPTION clause is an optional part of CREATE VIEW statement but it is very useful to make views consistent.Basically, the WITH CHECK OPTION clause prevents us from updating or inserting the rows which are not visible ... Read More

Join Words into a String in C#

Arjun Thakur
Updated on 22-Jun-2020 13:50:17

268 Views

Declare a string and add elements −string[] str = { "One", "Two", "Three", "Four", "Five" };Use the Join() method to join the words−string res = string.Join(" ", str);Let us see the complete code −Example Live Demousing System; public class Demo {    public static void Main() {       string[] str = { "One", "Two", "Three", "Four", "Five" };       // join words       string res = string.Join(" ", str);       Console.WriteLine(res);    } }OutputOne Two Three Four Five

C# Program to Separate Joined Strings in C#

Chandu yadav
Updated on 22-Jun-2020 13:49:53

75 Views

The following is the string array −string[] str = { "Java", "AngularJS", "Python", "jQuery", "HTML5" };Firstly, join it −string.Join(" ", str);Now to separate the above joined strings, use the Split() method as shown in the following code −Example Live Demousing System; public class Demo {    public static void Main() {       string[] str = { "Java", "AngularJS", "Python", "jQuery", "HTML5" };       // join words       string res = string.Join(" ", str);       Console.WriteLine("Joined Strings... "+res);       string[] convert = res.Split(' ');       Console.WriteLine("Separate Joined Strings..."); ... Read More

Boolean Array in C#

George John
Updated on 22-Jun-2020 13:49:25

9K+ Views

In a bool array, you can store true and false values. To set a bool array, use the new operator −bool[] arr = new bool[5];To add elements in the array −arr[0] = true; arr[1] = true; arr[2] = false; arr[3] = true; arr[4] = true;Let us see the complete code −Example Live Demousing System; public class Demo {    public static void Main() {       bool[] arr = new bool[5];       arr[0] = true;       arr[1] = true;       arr[2] = false;       arr[3] = true;       arr[4] = true;       Console.WriteLine("Displaying values...");       foreach (bool res in arr) {          Console.WriteLine(res);       }    } }OutputDisplaying values... True True False True True

Create MySQL View Based on Table Values and Conditions

Vikyath Ram
Updated on 22-Jun-2020 13:48:48

264 Views

If we want to create a view that takes the values from a table based on some particular condition(s) then we have to use WHERE clause while creating the view. The values depending upon the WHERE clause will be stored in view. The syntax of creating a MySQL view with WHERE clause can be as follows −SyntaxCreate View view_name AS Select_statements FROM table WHERE condition(s);ExampleTo illustrate the above concept, we are using the following data from table ‘Student_info’ −mysql> Select * from student_info; +------+---------+------------+------------+ | id   | Name    | Address    | Subject    | +------+---------+------------+------------+ | 101 ... Read More

Advertisements