Nizamuddin Siddiqui has Published 2307 Articles

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

Nizamuddin Siddiqui

Nizamuddin Siddiqui

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

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

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

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

How to force garbage collection in C#?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

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

2K+ Views

Yes it is possible to force garbage collector in C# to run by calling Collect() methodThis is not considered a good practice because this might create a performance over head. Collect() Forces an immediate garbage collection of all generations.Collect(Int32)Forces an immediate garbage collection from generation 0 through a specified generation.Example Live ... Read More

How to create an array with non-default repeated values in C#?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 19-Aug-2020 13:19:46

576 Views

We can create an array with non-default values using Enumerable.Repeat(). It repeated a collection with repeated elements in C#. Firstly, set which element you want to repeat and how many times.Example 1class Program{    static void Main(string[] args){       var values = Enumerable.Repeat(10, 5);       foreach ... Read More

How to make use of both Take and Skip operator together in LINQ C# Programming

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 19-Aug-2020 13:18:01

94 Views

We are creating two instances of the Employee class, e and e1. The e is assigned to e1. Both objects are pointing to the same reference, hence we will get true as expected output for all the Equals.In the second case we can observe that, even though properties values are ... Read More

How to make use of both Take and Skip operator together in LINQ C#?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 19-Aug-2020 13:15:01

3K+ Views

The Take operator is used to return a given number of elements from an array and the Skip operator skips over a specified number of elements from an array.Skip, skips elements up to a specified position starting from the first element in a sequence.Take, takes elements up to a specified ... Read More

What is Shallow Copy and how it is different from Deep Copy in C#?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 19-Aug-2020 12:59:31

867 Views

Shallow Copy −A shallow copy of an object copies the "main" object, but doesn’t copy the inner objects.The "inner objects" are shared between the original object and its copy.The problem with the shallow copy is that the two objects are not independent. If you modify the one object, the change ... Read More

How can we create a LOG filter for Logging purposes in C# ASP.NET WebAPI?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 19-Aug-2020 12:56:34

1K+ Views

Action filters are used to add extra logic before or after action methods execution. The OnActionExecuting and OnActionExecuted methods are used to add our logic before and after an action method is executed.Let us create create a LogAttribute that implemets ActionFilterAttribute which logs some information before and after action method ... Read More

How to do versioning with custom media type in C# ASP.NET WebAPI?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 19-Aug-2020 12:52:13

218 Views

Media types allow an API to inform the client how to interpret the data in the payload. In the HTTP protocol, Media Types are specified with identifiers like text/html, application/json, and application/xml, which correspond to HTML, JSON, and XML respectively, the most common web formats. There are other more APIspecific ... Read More

Advertisements