Ankith Reddy has Published 996 Articles

Default operator in C#

Ankith Reddy

Ankith Reddy

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

669 Views

Using the default, you can get the default value of every reference and value type. The expressions set as default are evaluated at compile-time.To get the default for int −default(int);To get the default for long −default(long)Let us see the code to display default values −Example Live Demousing System; public class ... Read More

Pair Class in C#

Ankith Reddy

Ankith Reddy

Updated on 22-Jun-2020 13:20:45

6K+ Views

The Pair class is the KeyValuePair class that stores a pair of values in a single list with C#.Declare KeyValuePair −var myList = new Liststring, int>>(); Now, add some elements: myList.Add(new KeyValuePair("Laptop", 1)); myList.Add(new KeyValuePair("Desktop System", 2)); myList.Add(new KeyValuePair("Tablet", 3)); myList.Add(new KeyValuePair("Mobile", 4)); myList.Add(new KeyValuePair("E-Book Reader", 5)); myList.Add(new KeyValuePair("LED", 6));Display ... 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

2K+ 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

2K+ 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

246 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

105 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

1K+ 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

1K+ 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

132 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

277 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

Advertisements