What are the different data structures in C#, C# Data structures examples

C# Data Structures Fundamental

In the .NET Framework we have data structures like array, stack, hashtable, queue, linkedlist etc.

There are more data structure can be found in NuGet packages, some are available at Github library.

In above list I explained how to use each different object in C# programming, now here let’s understand some difference among them.

Difference between Stack and Queue in C#

1. A Stack is an ordered list of elements where all insertions and deletions are made at the same end.
1. Queue is exactly the opposite of a Stack, means Queue object is used to insert data at one end, and to remove data from other end.
2. A Stack follows the LIFO (Last In First Out) principle.
2. Queue data structure follows the FIFO (First In First Out) principle
3. To add remove item from Stack item we use Push and Pop method.
3. To add remove item from Queue object we use enqueue and Pop dequeue methods.

difference between Hashtable and Dictionary in c#

1. A Hashtable is non-generic collection, Hashtable comes under System.Collections namespace.
1. A Dictionary is generic collection, Dictionary comes under System.Collections.Generic namespace.
2. In Hashtable, we can store key-value pairs of any data type, same or different.
2. In Dictionary, we can store key-value pairs of same data type only.
3. Hashtable doesn't maintain the order of stored values.
3. Dictionary maintain the order of stored values.
 
C# Delegates Example
Other Online Tutorial

C# .net Interview Questions Answers

Multicast Delegate Example
.Net C# Examples | Join .Net C# Course