Samual Sam has Published 2310 Articles

What are static or fixed length arrays in C#?

Samual Sam

Samual Sam

Updated on 21-Jun-2020 11:56:11

2K+ Views

A static array is a data structure with a fixed size. Let us see an example of a static array in C#.Here is a static string array. The data remains the same here i.e. fixed −static string[] _fruits = new string[] {    "apple",    "mango" };Now let us see ... Read More

What is a dictionary in C#?

Samual Sam

Samual Sam

Updated on 20-Jun-2020 17:34:34

3K+ Views

Dictionary is a collection of keys and values in C#. Dictionary is included in the System.Collection.Generics namespace.To declare and initialize a Dictionary −IDictionary d = new Dictionary();Above, types of key and value are set while declaring a dictionary object. An int is a type of key and string is a ... Read More

What is the best way to iterate over a Dictionary in C#?

Samual Sam

Samual Sam

Updated on 20-Jun-2020 17:32:59

2K+ Views

In a Dictionary collection, store any data type. Dictionary is a collection of keys and values in C#. Dictionary is included in the System.Collection.Generics namespace.Let us now see the best way to iterate over a Dictionary in C# −Firstly, let us create a dictionary −var d = new Dictionary(5);Now add ... Read More

What are multicasting delegates in C#?

Samual Sam

Samual Sam

Updated on 20-Jun-2020 17:30:17

2K+ Views

A delegate that holds a reference to more than one method is called multicasting delegate.Let us see an example −Exampleusing System; delegate void myDelegate(int val1, int val2); public class Demo {    public static void CalAdd(int val1, int val2) {       Console.WriteLine("{0} + {1} = {2}", val1, val2, ... Read More

Try-Catch-Finally in C#

Samual Sam

Samual Sam

Updated on 20-Jun-2020 17:26:18

7K+ Views

C# exception is a response to an exceptional circumstance that arises while a program is running, such as an attempt to divide by zero.C# exception handling is performed using the following keywords −try − A try block identifies a block of code for which particular exceptions is activated. It is ... Read More

volatile keyword in C#

Samual Sam

Samual Sam

Updated on 20-Jun-2020 17:21:20

764 Views

To reduce concurrency issues in C#, use the volatile keyword. Let us seen an example.The following is how you use a volatile keyword for public variable −class Program {    public volatile int a;    public void Program(int _a) {       i = _i;    } }Let us ... Read More

How to use LINQ to sort a list in C#?

Samual Sam

Samual Sam

Updated on 20-Jun-2020 17:11:01

708 Views

Use the LINQ orderby keyword to sort a list in C#.In the below example, we have set the orderby for the elements −var myLen = from element in myList orderby element.Length select element;Let us see an example −Example Live Demousing System; using System.Collections.Generic; using System.Linq; class Demo {    static ... Read More

What is ternary operator in C#?

Samual Sam

Samual Sam

Updated on 20-Jun-2020 16:53:30

338 Views

Ternary operator is a Conditional operator in C#. It takes three arguments and evaluates a Boolean expression.For example −y = (z == 1) ? 100 : 180;Above, if the first operand evaluates to true (1), the second operand is evaluated. If the first operand evaluates to false (0), the third ... Read More

What does the interface IStructuralEquatable do in C#?

Samual Sam

Samual Sam

Updated on 20-Jun-2020 16:03:02

413 Views

The IStructuralEquatable interface defines methods to support the comparison of objects for structural equality, which means that two objects are equal because they have equal values.It includes the following two methods −Sr.NoMethod & Description1Equals(Object,  IEqualityComparer)The method determined whether an object is structurally equal to the current instance.2GetHashCode(IEqualityComparer)The methods a hash ... Read More

What is serialization in C#.NET?

Samual Sam

Samual Sam

Updated on 20-Jun-2020 15:58:25

683 Views

Serialization converts objects into a byte stream and brings it to a form that it can be written on stream. This is done to save it to memory, file or database.Serialization can be performed as −Binary SerializationAll the members, even members that are read-only, are serialized.XML SerializationIt serializes the public ... Read More

Advertisements