C# Hashtable with example – How to use and when to use?

In this blog post, we will take a deep dive into C# hashtables, explaining what they are, how they work, and how to use them effectively in our C# code.

We will also cover some common scenarios where hashtables can be particularly useful, as well as some tips and best practices for working with them. By the end of this post, you should have a solid understanding of hashtables and how to leverage their power in your C# projects.

csharp-hashtable-class

Read more >>

Understanding C# Queue Class With Examples

C# Queue is a linear data structure that follows the First-In-First-Out (FIFO) principle. In other words, the first element added to the queue will be the first one to be removed. This makes queues useful for storing data that needs to be processed in a specific order. The queue is the opposite of the Stack<T> collection.

In C#, the Queue class is a generic collection that implements the IEnumerable interface and provides a variety of methods for adding, accessing, and removing elements in the queue.

csharp-queue
C# Queue

Read more >>

C# Polymorphism: Different types of polymorphism in C# with examples

Polymorphism is a Greek word that means “many-shaped” or multiple forms of an object. You can use polymorphism in case you want to have multiple forms of one or more methods of a class with the same name.

Polymorphism is one of the main key concepts of object-oriented programming after encapsulation and inheritance.

In this article, we are going to learn about the different types of polymorphism in C#, how they work, how to implement them, and how to use polymorphism in our program code.

polymorphism-in-csharp
Types of polymorphism in C#

Read more >>

C# Stack Class With Push And Pop Examples

Stack in C# represents a last-in, first-out (LIFO) collection of objects. It is useful when you need last-in, first-out access to elements. Adding an element to the stack is called a push operation, and removing an element from the stack is called a pop operation.

A Stack is a collection that can be both generic and non-generic. The generic stack is defined in the System.Collections.Generic namespace. A non-generic stack, on the other hand, is defined under System.Collections namespace. In this post, we will discuss a non-generic type stack.

C# Stack with Push and Pop Examples
C# Stack with Push and Pop operation

Read more >>

C# Tuple: How to work with a Tuples in C#?

A Tuple<T> is a data structure that allows you to combine multiple elements of different data types into a single object.
It was first introduced with .NET Framework 4.0 and allowed a maximum of eight elements to be stored. Attempting to store more than eight elements will result in a compiler error.

This article will explore how to work with C# Tuples and demonstrate their usage with simple code examples.

C# Tuple
C# Tuple

Read more >>

What Is Node.js and Why Should You Use It?

What Is Node.js?

Node.js is an open-source, cross-platform runtime environment and library for executing JavaScript code outside of a browser. It uses an event-driven, asynchronous, non-blocking I/O architecture, making it lightweight and efficient for data-intensive real-time applications running across distributed devices.

Node.js is neither a framework nor a programming language but a runtime environment. It was written and introduced by Ryan Dahl in 2009.
Node.js was built on top of chrome V8 JavaScript Engine that is written in C++ language. All the JavaScript code is executed by the V8 JavaScript engine; which converts the code into Assembly code, which is then converted into machine code. Machine code is something that a computer processor understands.

what-is-nodejs
what is node js

Read more >>

Top 10 Differences between Stored Procedure and Function in SQL Server

Stored procedures and functions are database objects which contain a set of SQL statements to execute a task. Both are different in many respects.

In this post, We will learn the differences between stored procedures and functions.

Before diving into the differences, it is important to understand the fundamental concepts such as stored procedures, functions, advantages, basic syntax, etc.

function-vs-stored-procedure-in-sql
Difference between Stored Procedure and Function in SQL Server

Read more >>

C# Dynamic Type: Var vs dynamic keywords in C#

The dynamic keyword is used to define dynamic types. Dynamic type is used to avoid compile-time type checking. The compiler does not type-check dynamic type variables at compile time, instead, the compiler check the type at the run time. If the syntax of the statement is invalid, an error will be thrown at runtime.

Dynamic types are similar to object types, despite the fact that type checking for object type variables occurs at compile time rather than at runtime for dynamic type variables.

csharp dynamic type
C# dynamic type

Read more >>

C# Unsafe Code: Why do we need unsafe code in C#?

Unsafe code in C#

In general, the code written in C# is safe code that doesn`t directly access memory using pointers. It also doesn’t allocate raw memory. Instead, managed objects are created.
On the other hand, unsafe code in C# usually refers to a section of code that is not processed by the CLR (Common Language Runtime) and directly access memory using pointers.

Since pointers are complex and might result in memory-related errors like stack overflow, overwritten system memory, etc., extra caution must be taken while handling unsafe code.
By default, pointers are not supported in C#. However, the use of pointer variables is permitted by the unsafe keyword.

charp unsafe code

Read more >>

C# Events: Top 5 Differences between delegates and events in C#

C# Events: The Events enable a class or object to notify other classes or objects when some interesting thing happens to the object. A class that sends or raises the event is called the publisher, and the classes that receive or handle the event are referred to as subscribers.

There can be multiple subscribers to a single event. Typically, when an action takes place, a publisher raises an event. The subscribers who want to be notified when an action takes place should register or subscribe to handle specific events.

The following diagram shows the event in C#.

csharp events
C# event model

Read more >>

C# Hashtable vs Dictionary: When should you use a Hashtable or a Dictionary?

“In C#, a hashtable is a non-generic collection that can store key/value pairs of any data type. On the other hand, A dictionary is a generic collection that can store key/value pairs of specific data types.”

In this article, we will learn the differences between the Hashtable and Dictionary with examples.

C# Hashtable vs Dictionary
C# Hashtable vs Dictionary

Read more >>

C# Arrays: Everything You Need to Know About Array in C#

C# Arrays: An Array is used to store multiple values in a single variable, rather than declaring a separate variable for each element. It is a fixed-sized sequential collection of elements of the same type.
The data types of the elements in an array can be int, char, float, string, and so on, and they are stored in a contiguous location.

C# Arrays
C# Arrays

Read more >>

Types of Comments in C#: Single Line, Multiline and XML Comments

Comments-in-C-Sharp
Comments in C#

Introduction: Comments in C#

Comments are used in a program to make a section of code easier to understand. They’re used to make the code more readable and provide a formal description of it and how it works. 

The compiler ignores comments, so you may put them wherever in a program and not worry about them breaking it.

Read more >>