Generics in C#: A Comprehensive Guide with Code Examples and Explanations

Generics in C# allow you to write type-safe, reusable, and efficient code. In this comprehensive guide, you will learn everything you need to know about generics including how to create generic classes, methods, collections, and generic constraints. This article contains valuable information about C# generics that will help both beginners and experienced C# developers enhance their coding abilities.

C# Generics allow you to reuse the same code (class or method) with different data types. It refers to a generalized version of something rather than a specialized version.

Generics in C#
Generics in C#

Read more >>

Top 5 Difference between Call by Value and Call by Reference

In this post, we’ll look at a simple but difficult interview question in C#: Call By Value vs Call By Reference.

This is a question that both fresher and experienced developers are asked in interviews. It’s one of the most frequently asked questions by technical interviewers.

Call by Value and Call by Reference
Difference between Call by Value and Call by Reference

Read more >>

ASP.NET Core Middleware With Examples

In ASP.NET Core, middleware is a component that can be plugged into the request processing pipeline to perform some action for each request. It sits between the server and the application and is responsible for handling requests and responses.

asp-net-core-middleware
asp-net-core-middleware

Read more >>

C# Collections – Understanding collections in C# with [Examples]

Collections in C#
C# Collections types

Collections in C#

A collection in C# is a class that represents a group of objects. Collections can be used to perform various operations on objects, such as storing, updating, deleting, retrieving, searching, and sorting.

Collections are defined in the System.Collections namespace. They are a predefined set of classes for storing multiple items in a single unit.

Read more >>

WCF vs Web API: Top 10 Differences Between WCF and Web API

WCF (Windows Communication Foundation) is a framework for building service-oriented applications. It allows communication between applications on different devices, across computers and networks. WCF is part of the .NET framework, and it provides a runtime environment for applications that use distributed communication.

Web API is a framework for building HTTP services. It is a part of the ASP.NET platform and it allows you to create RESTful (representational state transfer) services, which can be consumed by a wide range of clients including web browsers and mobile devices.

This article will provide a practical comparison of WCF and Web API to help you decide which is the better option for your needs. We will discuss the differences between these two frameworks in detail.

WCF VS WEB API
WCF VS WEB API

Read more >>

C# 10 New Features: A Comprehensive Guide with Code Examples

As a programming language, C# has gone through several iterations, and with each new version, we see new features and enhancements that make programming with it even better.
C# 10, the latest language version, is no exception.

In this article, we will explore the new features of C# 10 and provide examples of how to use them in your code.

C# 10 New Features
C# 10 New Features

Read more >>

C# Struct vs Class |Top 15+ Differences Between Struct and Class

Difference Between Struct and Class in C#:

One key difference between structs and classes is that Structs are value types, whereas classes are reference types.

In the case of structs, they are copied by value, meaning that a complete replica of the data is created when passed or assigned. On the other hand, classes are copied by reference, meaning that only a reference to the original data is passed around rather than a full duplication.

C# struct vs class
C# struct vs class

Read more >>

C# List with examples

In this article, we will learn about the C# list with the help of multiple examples.

List<T> is a dynamic collection that contains multiple objects of the same data type that can be accessed using an index.

It is similar to an array but can grow or shrink in size. Lists are commonly used to store and organize data in a sequential manner. It can dynamically perform operations like adding, searching, shorting, and removing elements from a collection.

The following diagram illustrates the methods and properties of the List<T> class.

C# List
List in C#

Read more >>

C# Access Modifiers: Everything You Need to Know (With Examples)

One of the fundamental features of C# is the use of access modifiers. These modifiers control the accessibility of classes, methods, and variables in your code.

In this article, we will take a comprehensive look at C# access modifiers, exploring their various types, their effects on code, and best practices for using them.

Access Modifiers in C#
C# Access Modifiers

Read more >>

C# Dictionary – How to Use a Dictionary in C# [With Examples]

A Dictionary in C# is a collection that stores a set of keys and values, similar to a Hashtable. Dictionaries are useful for storing data that needs to be quickly retrieved using a key.

  • In C#, a Dictionary<TKey, TValue> is a generic collection that stores key/value pairs data organized by the unique key.
  • In C#, the Dictionary class is part of the System.Collections.Generic namespace. It is a dynamic collection that can be resized on-the-fly, allowing you to add or remove items as needed. It means that you don’t have to pre-define the size of the dictionary, and it can grow or shrink depending on the data being stored.
C# Dictionary
C# Dictionary

Read more >>

Views in SQL Server with [Examples]

In SQL, Views are virtual tables that give a simplified and customized view of data from one or multiple database tables. They are similar to a table with rows and columns but do not store actual data.

This article will cover the different types of views in SQL Server with multiple examples. Also, we will learn about how to create, modify, update, and delete views in SQL Server.

View in SQL Server
Views in SQL Server

Read more >>

Triggers in SQL: Understanding Triggers and Trigger Examples in SQL Server

Triggers in SQL are special types of stored procedures that are automatically executed in response to specific events or changes within a database. In this article, we will explore triggers in SQL and provide a trigger example in SQL Server to help you understand how they work.

SQL Server Trigger Update, Insert, Delete
Triggers in SQL

Read more >>

C# Exception: C# Exception handling best practices

An exception is defined as an event that occurs during the program execution that is unexpected by the program code. Exception handling is important because it handles an unwanted exception so that your program code does not crash and remains meaningful to the user.

In this article, we will discuss the exception types and exception handling in C# using try, catch, and finally blocks.

exception handling in C#
C# Exception Handling

Read more >>

C# Enum: How to use enumeration type in C#?

What is an enum in C#?

An enum, or enumeration, is a value type in C# that consists of a set of named constants called the members of the enum. Enums are useful when you have a fixed set of values that a variable can take on, such as the days of the week or a set of predefined options.

Enums are value types, so they are stored in the stack rather than the heap. This means that they are faster to access than reference types, but they also take up more memory.

In this post, we will learn the proper usage of an enum in c# with multiple examples.

C# Enum
C# Enums

Read more >>