Easiest Way to Handle Csv Files in Csharp

Easiest Way to Handle Csv Files in Csharp

In this tutorial we will se how to read and write data to csv file. It is pretty much easy if you have some external library for that. We are definitely going to use a library and that will be CsvHelper.

You can also check the video version of this tutorial.

First and foremost, create a c# console application in .net core. After that we need to install a nuget package, which is**CsvHelper**

[Read More]

Multiple Ways to Find Duplicates in Csharp Array

Multiple Ways to Find Duplicates in Csharp Array

In C#, we can use various approaches to find duplicate elements in array. Each have pros and cons. We will use 3 approaches in this article.

  1. Using a HashSet
  2. Using a Dictionary
  3. Using LINQ

Lets take this array as an example, from this array we will extract distinct numbers and duplicate numbers.

int[] numbers = { 4,7, 2, 3, 4, 5, 3, 6, 7, 8,1, 8 };

We will use this array in all three approaches. So let’s understand one by one.

[Read More]

C# Dictionary and Its Use Cases

C# Dictionary and Its Use Cases

What is dictionary?

Dictionary is a collection, that store the value in the form of key value pair. It allows you to quick access of value using the key. This data structure is widely used in programming because of its fast look-up time, which makes it ideal for applications that require quick data retrieval

👉 You can not add duplicate key in dictionary

Creating a dictionary:

[Read More]

Catch Exception Globally in Dotnet Core Apis

Catch Exception Globally in Dotnet Core Apis

There are to ways of catching exception in .net core, one is using try/catch and other one is catching them globally. Although there is nothing wrong with try/catch blog, it is an elegant way of exception handling. Although you can also catch exceptions globally, If you want to log errors in one place. There are various approaches to achieve this, but we will create the custom middleware to achieve it.

[Read More]

Output Caching With Dotnet 7

Output Caching With Dotnet 7

What is Caching?

Caching is a process of temporarily storing frequently accessed data or resources in a faster and closer location to the user or application, with the goal of reducing the time and resources needed to retrieve that data from its original source. By keeping a copy of the data nearby, caching enables quicker access and improves the overall performance and responsiveness of applications.

[Read More]

JWT Authentication and Role Based Authorization in Dotnet Core

JWT Authentication and Role Based Authorization in Dotnet Core

JWT

According to jwt.io JSON Web Tokens are an open, industry standard RFC7519 method for representing claims securely between two parties.

When we create REST APIs, then we don’t want that any one can access those apis. REST APIs, will only be accessed by the authenticated user. We authenticate our user with the help of jwt.

How jwt works?

First, we give an authentication endpoint to user, where he/she puts credential, in return we give a jwt token to user which have an expiry date. To consume any protected resource, user need to pass jwt token on authorization header.

[Read More]

Create Sln File With Multiple Projects

Create Sln File With Multiple Projects

In this article we will learn how to create a .net core project with a Solution (sln file) that contains multiple projects. I know most you guys use visual studio for c# related stuff, but it would be benificial for person who likes to switch with vs code ocassionally, like me or who use linux and forced to use .net cli. Although if you are a new developer and have windows operating system, I will recommend visual studio, because it is the best possible IDE for c# development.

[Read More]

Ngrx Entity and Effects

Ngrx Entity and Effects

NGRX Entity gives you an efficient and quick way to deal with ngrx store related operations, such as read, write, update, delete. You can focus on productivity, rather than creating and modifeng complex state everytime. It can be very helpful when you are dealing with complex state and handling with http services at the same time.

What is ngrx ?

Ngrx is a state management library, that stores the state globally. Lets understand some of its components.

[Read More]

Api Versioning in Dotnet Core

Api Versioning in Dotnet Core

Photo by Jan Loyde Cabrera at medium.com

When you are going to do some breaking changes in your apis, it is better to create a new version for that, so that user don’t freaked out. They still can use the older APIs and get ready for new changes. There are various way to create a versions of your APIs like

  1. Query string
  2. URL
  3. HTTP header

If you prefer video version then you can checkout this video with same content.

[Read More]

Angular Autocomlete With Ng Select

Angular Autocomlete With Ng Select

There are various packages available for implementing autocomplete in angular and we are going to use the simplest one (ng-select).

Let’s finish talking and need to start write code. Let’s install ng-select package from command line

npm install --save @ng-select/ng-select

[Read More]