Karthikeya Boyini has Published 2383 Articles

How can I generate days from the range of dates with the help of MySQL views?

karthikeya Boyini

karthikeya Boyini

Updated on 22-Jun-2020 14:11:56

228 Views

To illustrate it we are creating the following views −mysql> CREATE VIEW digits AS     -> SELECT 0 AS digit UNION ALL     -> SELECT 1 UNION ALL     -> SELECT 2 UNION ALL     -> SELECT 3 UNION ALL     -> SELECT 4 UNION ... Read More

C# program to find the index of an element in a List

karthikeya Boyini

karthikeya Boyini

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

709 Views

Set a list and add elements −List val = new List(); // integer elements val.Add(35); val.Add(55); val.Add(68);Let’s say now we need to find the index of element 68. For that, use the IndexOf() method −int index = val.IndexOf(68);Here is the complete code −Example Live Demousing System; using System.Collections.Generic; public class ... Read More

C# Program to find the smallest element from an array using Lambda Expressions

karthikeya Boyini

karthikeya Boyini

Updated on 22-Jun-2020 14:09:40

407 Views

Declare an array −int[] arr = { 10, 15, 5, 20};Now to get the smallest element from an array, use Min() method with lambda expressions −arr.Min());Here is the complete code −Example Live Demousing System; using System.Linq; class Demo {    static void Main() {       int[] arr = { ... Read More

C# program to get the List of keys from a Dictionary

karthikeya Boyini

karthikeya Boyini

Updated on 22-Jun-2020 14:08:38

5K+ Views

Set the dictionary elements −Dictionary d = new Dictionary(); // dictionary elements d.Add(1, "One"); d.Add(2, "Two"); d.Add(3, "Three"); d.Add(4, "Four"); d.Add(5, "Five"); d.Add(6, "Six"); d.Add(7, "Seven"); d.Add(8, "Eight");To get the keys, use a list collection −List keys = new List(d.Keys);Loop through the keys and display them.Here is the complete ... Read More

Insert more than one element at once in a C# List

karthikeya Boyini

karthikeya Boyini

Updated on 22-Jun-2020 14:07:28

2K+ Views

Use the InsertRange() method to insert a list in between the existing lists in C#. Through this, you can easily add more than one element to the existing list.Let us first set a list −List arr1 = new List(); arr1.Add(10); arr1.Add(20); arr1.Add(30); arr1.Add(40); arr1.Add(50);Now, let us set an array. The ... Read More

Remove duplicates from a List in C#

karthikeya Boyini

karthikeya Boyini

Updated on 22-Jun-2020 14:06:01

6K+ Views

Use the Distinct() method to remove duplicates from a list in C#.Firstly, add a new list −List arr1 = new List(); arr1.Add(10); arr1.Add(20); arr1.Add(30); arr1.Add(40); arr1.Add(50); arr1.Add(30); arr1.Add(40); arr1.Add(50);To remove duplicate elements, use the Distinct() method as shown below −List distinct = arr1.Distinct().ToList();Here is the complete code −Example Live Demousing System; ... Read More

C# Program to Subtract Two TimeSpan

karthikeya Boyini

karthikeya Boyini

Updated on 22-Jun-2020 14:04:46

350 Views

Firstly, set two TimeSpans −TimeSpan t1 = TimeSpan.FromMinutes(2); TimeSpan t2 = TimeSpan.FromMinutes(1);To add it, use the Subtract() method −imeSpan res = t1.Subtract(t2);Here is the complete code −Example Live Demousing System; using System.Linq; public class Demo {    public static void Main() {       TimeSpan t1 = TimeSpan.FromMinutes(2);     ... Read More

C# program to copy a range of bytes from one array to another

karthikeya Boyini

karthikeya Boyini

Updated on 22-Jun-2020 14:01:56

3K+ Views

Use the Buffer.BlockCopy method to copy a range of bytes from one array to another −Set a byte array −byte[] b1 = new byte[] {22, 49}; byte[] b2 = new byte[5];Copy bytes from one array to another −Buffer.BlockCopy(b1, 0, b2, 0, 2);The following is the complete code −Example Live Demousing System; ... Read More

C# Program to convert integer array to string array

karthikeya Boyini

karthikeya Boyini

Updated on 22-Jun-2020 14:00:24

1K+ Views

Use the ConvertAll method to convert integer array to string array.Set an integer array −int[] intArray = new int[5]; // Integer array with 5 elements intArray[0] = 15; intArray[1] = 30; intArray[2] = 44; intArray[3] = 50; intArray[4] = 66;Now use Array.ConvertAll() method to convert integer array to string ... Read More

C# program to find the last matching element in an array

karthikeya Boyini

karthikeya Boyini

Updated on 22-Jun-2020 13:59:37

295 Views

To find the last matching element, use the Array.LastIndexOf method. Returns -1 if the element isn’t present in the integer array.The following is the array −int[] val = { 97, 45, 76, 21, 89, 45 };Now, let’s say you need to search the last Index of element 45. For that, ... Read More

Advertisements