Export Collection of data to Excel in c# using Closed XML

ClosedXML is a .NET library for reading, manipulating and writing Excel files.  ClosedXML is a fine library for exporting data to Excel. It is very simple to use and fast enough for smaller sets of data. Firstly you have to add reference to ClosedXML. Install ClosedXML using NuGet Package Manager. Using ClosedXML you can set … Continue reading Export Collection of data to Excel in c# using Closed XML

Mock HttpContext using moq Framework

Moq is a framework that allows us to simulate dependencies at test time and monitor how our system under test interacts with them under various circumstances. Mock objects allow you to mimic the behavior of classes and interfaces, letting the code in the test interact with them as if they were real.  In a project … Continue reading Mock HttpContext using moq Framework

Parallel.ForEach() Vs Foreach() Loop in C#

Foreach Loop Foreach loop runs upon a single thread and processing takes place sequentially one by one. Foreach loop is a basic feature of C#.  Its execution is slower than Parallel.Foreach in most of the cases. Syntax foreach( var item in list){          DoFunction(item); } The problem with this foreach is that item 1000 has to wait until … Continue reading Parallel.ForEach() Vs Foreach() Loop in C#

Coding standards and Naming conventions

This post will helps you to understand basic coding conventions. A consistent naming pattern is one of the most important elements of predictability and discover-ability in a managed class library. Purposes of coding conventions They create a consistent look to the code, so that readers can focus on content, not layout. They enable readers to … Continue reading Coding standards and Naming conventions

Add CSS file while generating PDF using ITextSharp

This post will helps you to add CSS file while generating PDF. Using ITextSharp we can easily convert HTML to PDF. Below example will convert HTML to PDF with CSS files. Step1: Create a new MVC Project Step 2: Install  the ITextSharp Packages (Version 5)   Install ITextSharp packages from Nuget package manager. Step 3: … Continue reading Add CSS file while generating PDF using ITextSharp