Ankith Reddy has Published 1070 Articles

Concat Method in C#

Ankith Reddy

Ankith Reddy

Updated on 22-Jun-2020 12:59:51

162 Views

To concat lists in C#, ue the Concat method.The following is the list −var list1 = new List{12, 40}; var list2 = new List{98, 122, 199, 230};Here is the Concat method −var res = list1.Concat(list2);The following is the example to work with Concat method −Example Live Demousing System.Collections.Generic; using System.Linq; using ... Read More

What are the benefits of using MySQL views as compared to selecting data directly from MySQL base tables?

Ankith Reddy

Ankith Reddy

Updated on 22-Jun-2020 12:57:20

1K+ Views

As we know that views are definitions built on the top of other tables or views and stored in the database. Followings are benefits of using MySQL views as compared to selecting data directly from MySQL base tablesSimplify data accessThe use of views simplifies the data access because of the ... Read More

How to convert a JavaScript array to C# array?

Ankith Reddy

Ankith Reddy

Updated on 22-Jun-2020 12:52:47

1K+ Views

Let us say our JavaScript array is −    var myArr = new Array(5);    myArr[0] = "Welcome";    myArr[1] = "to";    myArr[2] = "the";    myArr[3] = "Web";    myArr[4] = "World"; Now, convert the array into a string using comma as a separator −document.getElementById('demo1').value = myArr.join(', ');Now, ... Read More

How can we get the metadata of MySQL events?

Ankith Reddy

Ankith Reddy

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

151 Views

It can be done with the help of the INFORMATION_SCHEMA database. The following statement will give us the metadata of events −mysql> SELECT * from INFORMATION_SCHEMA.EVENTS WHERE EVENT_NAME LIKE '%event%' A ND EVENT_SCHEMA = 'query'\G *************************** 1. row ***************************       EVENT_CATALOG: def        EVENT_SCHEMA: query ... Read More

C# ToEven property

Ankith Reddy

Ankith Reddy

Updated on 22-Jun-2020 12:44:49

55 Views

The ToEven property is used with the MidpointRounding Enumeration to round a number to the nearest even number.Declare and initialize a decimal number −decimal val = 70.45M;To rounde a number to the nearest even number −decimal.Round(val, 0, MidpointRounding.ToEven)Here is the complete code −Example Live Demousing System; using System.Linq; class Demo ... Read More

Conversion of ArrayList to Array in C#

Ankith Reddy

Ankith Reddy

Updated on 22-Jun-2020 12:38:40

944 Views

To convert an ArrayList to Array, use the ToArray() method in C#.Firstly, set an ArrayList −ArrayList arrList = new ArrayList(); arrList.Add("one"); arrList.Add("two"); arrList.Add("three");Now, to convert, use the ToArray() method −arrList.ToArray(typeof(string)) as string[];Let us see the complete code −Example Live Demousing System; using System.Collections; public class Program {    public static ... Read More

How to truncate a file in C#?

Ankith Reddy

Ankith Reddy

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

695 Views

To truncate a file in C#, use the FileStream.SetLength method.Here is the syntax −public override void SetLength (long value);Here, int64 = Length of the streamValue < current LengthIf the value is less than the current length of the stream: The stream is truncated. If the current position is greater than ... Read More

How can we put schedule for different kinds of MySQL events?

Ankith Reddy

Ankith Reddy

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

81 Views

Basically, there are two kinds of events for which we need to specify the schedule −One-time eventOne-time event means it will be executed only once on a particular schedule. If we want to create a one-time event then we need to put the following syntax after ON SCHEDULE clause −AT ... Read More

How to loop through all the elements of an array in C#?

Ankith Reddy

Ankith Reddy

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

183 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 ... Read More

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

Ankith Reddy

Ankith Reddy

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

3K+ Views

To initialize a string to an empty list −string myStr = null;Now, use the built-in method IsNullOrEmpty() to check whether the list is empty or not −if (string.IsNullOrEmpty(myStr)) {    Console.WriteLine("String is empty or null!"); }Let us see the complete code −Example Live Demousing System; namespace Demo {    class ... Read More

Advertisements