Nizamuddin Siddiqui has Published 2303 Articles

What are Deconstructors in C# 7.0?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 19-Aug-2020 13:47:24

217 Views

C# allows to use multiple deconstructor methods in the same program with the same number of out parameters or the same number and type of out parameters in a different order.It's a part of the new tuple syntax - which has nothing to do with the Tuple classes but is ... Read More

What are the improvements in Out Parameter in C# 7.0?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 19-Aug-2020 13:45:14

226 Views

We can declare out values inline as arguments to the method where they're used.The existing out parameters has been improved in this version. Now we can declare out variables in the argument list of a method call, rather than writing a separate declaration statement.Advantages −The code is easier to read.No ... Read More

What is difference between using if/else and switch-case in C#?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 19-Aug-2020 13:43:48

504 Views

Switch is a selection statement that chooses a single switch section to execute from a list of candidates based on a pattern match with the match expression.The switch statement is often used as an alternative to an if-else construct if a single expression is tested against three or more conditions.Switch ... Read More

How to implement interface in anonymous class in C#?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 19-Aug-2020 13:39:59

2K+ Views

No, anonymous types cannot implement an interface. We need to create your own type.Anonymous types provide a convenient way to encapsulate a set of read-only properties into a single object without having to explicitly define a type first.The type name is generated by the compiler and is not available at ... Read More

How to write retry logic in C#?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 19-Aug-2020 13:38:37

1K+ Views

Retry logic is implemented whenever there is a failing operation. Implement retry logic only where the full context of a failing operation.It's important to log all connectivity failures that cause a retry so that underlying problems with the application, services, or resources can be identified.Exampleclass Program{    public static void ... Read More

What is the difference between Monitor and Lock in C#?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 19-Aug-2020 13:36:43

2K+ Views

Both Monitor and lock provides a mechanism that synchronizes access to objects. lock is the shortcut for Monitor.Enter with try and finally.Lock is a shortcut and it's the option for the basic usage. If we need more control to implement advanced multithreading solutions using TryEnter() Wait(), Pulse(), & PulseAll() methods, ... Read More

How to sort a list of complex types using Comparison delegate in C#?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 19-Aug-2020 13:32:43

609 Views

Overloads of the Sort() method in List class expects Comparison delegate to be passed as an argument.public void Sort(Comparison comparison)CompareTo returns an integer that indicates whether the value of this instance is less than, equal to, or greater than the value of the specified object or the other Int16 instance.The ... Read More

How to make use of Join with LINQ and Lambda in C#?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 19-Aug-2020 13:30:09

11K+ Views

Inner join returns only those records or rows that match or exists in both the tables. We can also apply to join on multiple tables based on conditions as shown below. Make use of anonymous types if we need to apply to join on multiple conditions.In the below example we ... Read More

What is if/then directives for debug vs release in C#?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 19-Aug-2020 13:27:28

2K+ Views

In Visual Studio Debug mode and Release mode are different configurations for building your .Net project.Select the Debug mode for debugging step by step their .Net project and select the Release mode for the final build of Assembly file (.dll or .exe).To change the build configuration −From the Build menu, ... Read More

How to get the Unix timestamp in C#

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 19-Aug-2020 13:26:03

7K+ Views

A Unix timestamp is mainly used in Unix operating systems. But it is helpful for all operating systems because it represents the time of all time zones.Unix Timestamps represent the time in seconds. The Unix epoch started on 1st January 1970.So, Unix Timestamp is the number of seconds between a ... Read More

Advertisements