Arjun Thakur has Published 1109 Articles

C# Program to split parts in a Windows directory

Arjun Thakur

Arjun Thakur

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

448 Views

Firstly, set a string i.e. your Windows directory path −string str = @"D:\Downloads\Amit";Now use the Split() method and split wherever the \ occur −str.Split(' \')The following is the complete code −Example Live Demousing System; class Program {    static void Main() {       string str = @"D:\Downloads\Amit";     ... Read More

Usage of CSS :focus pseudo-class

Arjun Thakur

Arjun Thakur

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

87 Views

You can try to run the following code to implement :focus pseudo-classExampleLive Demo                    input:focus {             background-color: orange;          }                              Subject          Student:          Age:                     Output

Get all drives in C#

Arjun Thakur

Arjun Thakur

Updated on 22-Jun-2020 14:31:43

549 Views

Firstly, use GetDrives to get the name of all the drives −var drv = DriveInfo.GetDrives();Loop through to get the name of all the drives on the system −foreach (DriveInfo dInfo in drv) {    Console.WriteLine(dInfo.Name); }Let us see the complete code −Example Live Demousing System; using System.Linq; using System.IO; public class ... Read More

Skip method in C#

Arjun Thakur

Arjun Thakur

Updated on 22-Jun-2020 14:30:05

5K+ Views

Use the Skip() method in C# to skip number of elements in an array.Let’s say the following is our array −int[] arr = { 10, 20, 30, 40, 50 };To skip the first two elements, use the Skip() method and add argument as 2 −arr.Skip(2);Let us see an example −Example Live ... Read More

Sort KeyValuePairs in C#

Arjun Thakur

Arjun Thakur

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

600 Views

Use the Sort method to sort the KeyValuePairs collection.Firstly, set the collection −var myList = new List(); // adding elements myList.Add(new KeyValuePair(1, 20)); myList.Add(new KeyValuePair(2, 15)); myList.Add(new KeyValuePair(3, 35)); myList.Add(new KeyValuePair(4, 50)); myList.Add(new KeyValuePair(5, 25));To sort, use the Sort() method. With that, we have used the CompareTo() method to ... Read More

How can we create MySQL view by selecting data based on pattern matching from base table?

Arjun Thakur

Arjun Thakur

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

99 Views

MySQL LIKE operator is used to select data based on pattern matching. Similarly, we can use LIKE operator with views to select particular data based on pattern matching from the base table. To understand this concept we are using the base table ‘student_info’ having the following data −mysql> Select * from Student_info; ... Read More

C# Program to get the difference between two dates

Arjun Thakur

Arjun Thakur

Updated on 22-Jun-2020 14:18:30

3K+ Views

Use DateTime.Subtract to get the difference between two dates in C#.Firstly, set two dates −DateTime date1 = new DateTime(2018, 8, 27); DateTime date2 = new DateTime(2018, 8, 28);Use the Subtract method to get the difference −TimeSpan t = date2.Subtract(date1);The following is the complete code −Example Live Demousing System; using System.Threading; using ... Read More

Convert string to bool in C#

Arjun Thakur

Arjun Thakur

Updated on 22-Jun-2020 14:15:52

2K+ Views

To convert a string to a bool, use the Bool.parse method in C# −Firstly, set a string −string str = "false";Now, convert it to bool −bool.Parse(str);Here is the complete code −Example Live Demousing System; using System.Linq; class Demo {    static void Main() {       string str = "false"; ... Read More

C# Program to display the number of days in a month

Arjun Thakur

Arjun Thakur

Updated on 22-Jun-2020 14:12:25

597 Views

Use the DaysInMonth to display the number of days in a month.Add the year and month as a parameter for the DaysInMonth() method −DateTime.DaysInMonth(2018, 8);The following is an example −Example Live Demousing System; using System.Collections.Generic; using System.Linq; public class Demo {    public static void Main() {       Console.WriteLine("Today ... Read More

Represent exact representation of no time in C#

Arjun Thakur

Arjun Thakur

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

41 Views

Use the TimeSpan.Zero to represent the exact representation of no time i.e −00:00:00Set an object for TimeSpan −TimeSpan ts;Now, the TimeSpan.Zero is used to display no time −TimeSpan ts = TimeSpan.Zero;Example Live Demousing System; using System.Linq; public class Demo {    public static void Main() {       TimeSpan ts ... Read More

Advertisements