Abstract Class in C#

In c#, Abstract class is a class that can not be instantiated on its own

abstract class in c#

  • In c#, Abstract class is a class that can not be instantiated on its own
  • It is typically used as a base class for other class.
  • Abstract class provides a way to achieve abstraction, because there you can just declare the methods (abstract methods) and implement them later.
  • It can contain both abstract methods (methods without implementation details) and non-abstract methods (method with implementation details).
  • Similar goal can be achieved with interface, but in abstract class you can also define non-abstract method. These methods are needed when you need to share some common functionality.
public abstract class Shape
{
 // it is the basic syntax of abstract class
}

Example:

[Read More]

Polymorphism in depth with C#

polymorphism in csharp

Polymorphism is one of the core concept of object oriented programming. Word polymorphism = poly (many) + morphism (forms). As its name suggesting polymorphism means, an entity can have multiple forms.

📢 Updated and refinded at : 21-feb-2025

Other oops core concepts :

Let’s learn polymorphism through mistakes.

Jim requires an entry system for his pet shop, which exclusively houses various breeds of dogs. This system will manage the entry and records of all dogs entering and exiting the premises.

[Read More]

Inheritance in C#

inheritance csharp

📢 Updated and refinded at : 21-feb-2025

Inheritance is a fundamental concept in OOPs that allows a class to inherit properties and behaviors of another class. We have two key terms are here base class/superclass and derived class/subclass.

  • Base class / super-class: Whose members and functionality are inherited (Giver).
  • Derived class / sub-class: Who is inheriting the members (Taker)

📺Other oops concepts:

Syntax of inheritance:

[Read More]

Encapsulation in C#

encapsulation in c#

📢 Updated and refinded at : 21-feb-2025

Bundling the data member and member function into a single unit is called encapsulation. Remember the term “capsule”. We put all the medicine inside a wrapper and call it capsule. Similarly, wrap the data members and member functions together is called encapsulation.

Now we need to understand few terms.

  • Data members : Attributes or properties (eg. name, age)
  • Member functions: Methods (PrintDetails)

👉 We wrap up the data members (attributes or properties) and member functions (methods) into a single unit (class).

[Read More]

Abstraction in C#

abstraction in oops c#

📢 Updated and refinded at : 21-feb-2025

Abstraction allows you to focus on the relevant details of an object while ignoring unnecessary complexities.
This is achieved by defining a simplified representation of an object that hides the implementation details and exposes only the necessary features.
In practical terms, abstraction is implemented through abstract classes and interfaces in languages like C#.

📺Other OOPs related articles :

Let’s implement abstraction by using interface. In the real world projects, we use interfaces more often.

[Read More]

Fluent Validation in Dotnet Core

fluent validation in asp.net core

Fluent validation

Fluent validation is an open source library for validating the models, which is free as of I am writing this article.

📢 📝 Last Updated: 25-March-2025

Why fluent validation?

If you already have used data annotation for validation, then you must be aware of the validation in .NET. So you might be thinking why do we need a fluent validation then.

Fluent validation helps you to separate validation logic from your models. That makes your code clean. If you have complex validation logic, then you want to define it separately rather than making your model unreadable.

[Read More]

Uploading Images in Blazor Server

upload files in blazor server

In this blog post we are going to learn how to upload files in the blazor server application. I am going to upload images in this tutorial but you can upload any file (i have created reusable code).

đź’»Source Code: https://github.com/rd003/BlazorFile/

High level overview

We will upload images to a folder of a local machine ( on a production you have to use cloud storage) with a unique name (e.g. sd$3abccc3$1.png ), that name is going to save in database.

[Read More]

Easiest Way to Handle Csv Files in Csharp

how to read and write to csv files in c#

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

find duplicates in c# 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

Use cases of c# dictionary

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]