Chandu yadav has Published 1091 Articles

Buffer SetByte Example in C#

Chandu yadav

Chandu yadav

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

292 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

257 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

774 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

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

70 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

622 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

UnionWith Method in C#

Chandu yadav

Chandu yadav

Updated on 22-Jun-2020 13:09:51

683 Views

Use the UnionWith method in C# to get the union of i.e. unique lements from two collections.Let’s say the following are our Dictionary −Dictionary < string, int > dict1 = new Dictionary < string, int > (); dict1.Add("pencil", 1); dict1.Add("pen", 2); Dictionary < string, int > dict2 = new Dictionary ... Read More

C# program to find Union of two or more Dictionaries

Chandu yadav

Chandu yadav

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

695 Views

Firstly, set both the dictionaries −Dictionary < string, int > dict1 = new Dictionary < string, int > (); dict1.Add("water", 1); dict1.Add("food", 2); Dictionary < string, int > dict2 = new Dictionary < string, int > (); dict2.Add("clothing", 3); dict2.Add("shelter", 4);Now, create HashSet and use UnionsWith() method to find the ... Read More

C# program to concat two or more Lists

Chandu yadav

Chandu yadav

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

229 Views

Set three lists −// three lists var list1 = new List{3, 4}; var list2 = new List{1, 2, 3}; var list3 = new List{2, 5, 6};Now, use the Concat mthod to concat the above lists −var res1 = list1.Concat(list2); var res2 = res1.Concat(list3);Here is the complete code −Example Live Demousing System.Collections.Generic; ... Read More

Advertisements