- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Karthikeya Boyini has Published 2383 Articles
karthikeya Boyini
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
karthikeya Boyini
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
karthikeya Boyini
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
karthikeya Boyini
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
karthikeya Boyini
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
karthikeya Boyini
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
karthikeya Boyini
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
karthikeya Boyini
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
karthikeya Boyini
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
karthikeya Boyini
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