Samual Sam has Published 2492 Articles

Try-Catch-Finally in C#

Samual Sam

Samual Sam

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

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

589 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

583 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

241 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

250 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 Regex class and its class methods in C#?

Samual Sam

Samual Sam

Updated on 20-Jun-2020 16:00:18

151 Views

The Regex class is used for representing a regular expression. A regular expression is a pattern that could be matched against an input text.The following are the methods of Regex class −Sr.NoMethod & Description1public bool IsMatch(string input)Indicates whether the regular expression specified in the Regex constructor finds a match in ... Read More

What is serialization in C#.NET?

Samual Sam

Samual Sam

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

530 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

What is compile time polymorphism in C#?

Samual Sam

Samual Sam

Updated on 20-Jun-2020 15:55:55

1K+ Views

Polymorphism can be static or dynamic. In static polymorphism, the response to a function is determined at the compile time. In dynamic polymorphism, it is decided at run-time.The linking of a function with an object during compile time is called early binding. It is also called static binding. C# provides ... Read More

What is late binding in C#?

Samual Sam

Samual Sam

Updated on 20-Jun-2020 15:48:03

924 Views

In static polymorphism, the response to a function is determined at the compile time. In dynamic polymorphism, it is decided at run-time. Dynamic polymorphism is what we call late binding.Dynamic polymorphism is implemented by abstract classes and virtual functions. The following is an example showing an example of dynamic polymorphism ... Read More

How to pass pointers as parameters to methods in C#?

Samual Sam

Samual Sam

Updated on 20-Jun-2020 15:39:11

2K+ Views

To pass pointers as parameters to methods, refer the below steps −Firstly, crate a function swap with unsafe modifier.public unsafe void swap(int* p, int *q) {    int temp = *p;    *p = *q;    *q = temp; }Now under static void main, add the value for the first ... Read More

Advertisements