Chandu yadav has Published 1163 Articles

TimeSpan.From methods in C# ()

Chandu yadav

Chandu yadav

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

104 Views

The TimeSpan.From methods include FromDays, FromHours, FromMinutes, etc.To get the TimeSpan for all the methods// Days TimeSpan t1 = TimeSpan.FromDays(1); // Hours TimeSpan t2 = TimeSpan.FromHours(1); // Minutes TimeSpan t3 = TimeSpan.FromMinutes(1);The following is the code that works on all the TimeSpan methods −Example Live Demousing System; using System.Linq; ... Read More

Format TimeSpan in C#

Chandu yadav

Chandu yadav

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

2K+ Views

You can format a TimeSpan in the hh: mm: ss format in C#.Firstly, set the TimeSpan −TimeSpan ts = new TimeSpan(9, 15, 30);To format TimeSpan −{0:hh\:mm\:ss}The following is the code −Example Live Demousing System; using System.Linq; public class Demo {    public static void Main() {       TimeSpan ts ... Read More

How can we use logical operators while creating MySQL views?

Chandu yadav

Chandu yadav

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

138 Views

MySQL views can be created by using logical operators like AND, OR, and NOT. It can be illustrated with the help of following examples −Views with AND operatorAs we know that logical AND operator compares two expressions and returns true if both the expressions are true. In the following example, ... Read More

Buffer SetByte Example in C#

Chandu yadav

Chandu yadav

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

182 Views

The SetByte() method assigns a specified value to a byte at a particular location in a specified array.Firstly, set an array −int[] arr = { 3, 4, 12 };Now, use SetByte() to assign values −Buffer.SetByte(arr, 3, 20);Here is the complete code −Example Live Demousing System; using System.Text; public class Demo { ... Read More

C# NullReferenceException

Chandu yadav

Chandu yadav

Updated on 22-Jun-2020 13:56:42

224 Views

NullReferenceException occurs when you try to to access member fields, or function types that points to null.Here is an example −Example Live Demousing System; class Demo {    static void Main() {       string str = null;       if (str.Length > 0) {     ... Read More

Buffer BlockCopy in C#

Chandu yadav

Chandu yadav

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

517 Views

It copies the bytes from one byte array to another byte array.Example Live Demousing System; class Demo {    static void Main() {       // byte arrays       byte[] b1 = new byte[] {55, 66, 77, 88, 99};       byte[] b2 = new byte[8];   ... Read More

C# program to iterate over a string array with for loop

Chandu yadav

Chandu yadav

Updated on 22-Jun-2020 13:52:06

2K+ Views

Create a string array −string[] str = new string[] {    "Videos",    "Tutorials",    "Tools",    "InterviewQA" };Loop until the length of the array −for (int i = 0; i < str.Length; i++) {    string res = str[i];    Console.WriteLine(res); }Here is the complete code −Example Live Demousing System; ... Read More

C# program to separate joined strings in C#

Chandu yadav

Chandu yadav

Updated on 22-Jun-2020 13:49:53

41 Views

The following is the string array −string[] str = { "Java", "AngularJS", "Python", "jQuery", "HTML5" };Firstly, join it −string.Join(" ", str);Now to separate the above joined strings, use the Split() method as shown in the following code −Example Live Demousing System; public class Demo {    public static void Main() ... Read More

Default value of bool in C#

Chandu yadav

Chandu yadav

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

2K+ Views

Use the default operator to get the default value of bool type −bool a = default(bool);Above, we have used the default keyword to get the default value.Let us see the code to display default value of bool −Example Live Demousing System; public class Demo {    public static void Main() ... Read More

Difference between Dictionary and Hashtable in C#

Chandu yadav

Chandu yadav

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

491 Views

Hashtable is slower than Dictionary. For strongly-typed collections, the Dictionary collection is faster.HashtableHashtable class represents a collection of key-and-value pairs that are organized based on the hash code of the key. It uses the key to access the elements in the collection.Let us see an example −Example Live Demousing System; using ... Read More

Advertisements