Introduction to Built-in Data Structures in C#
Last Updated :
23 Jul, 2025
In the C#, we have data structures like a dictionary, array, stack, hashtable, queue, Linkedlist, etc. Each data structure allows us to play with the collection of data with different principles.
Let’s see what inbuilt Data Structures C# offers us:
|
System.Array base class.
| Static
|
It is based on an internal array-like structure that can dynamically change in size.
| Dynamic
|
An array (also known as a circular buffer or ring buffer) with a front and rear pointer.
| Dynamic
|
An array of "buckets" (also known as "slots").
| Dynamic
|
Uses a hash table as its internal data structure for efficient storage and retrieval of key-value pairs.
| Dynamic
|
Implement a doubly-linked list.
| Dynamic
|
C# Arrays:
An array in C# is a collection of elements of the same type stored in the exact memory location. For example, in C#, an array is an object of base type "System.Array". The array index in C# starts at 0. In a C# array, you can only store a fixed number of elements.
C# Stack:
Stack
is a special type of collection that stores elements in LIFO style (Last In First Out). C# includes the generic Stack<T>
and non-generic Stack
collection classes. It is recommended to use the generic Stack<T>
collection.
C# Queue:
A Queue in C# represents a first-in, first-out (FIFO) collection of objects. An example of a queue is a line of people waiting.
The Queue<T> class in the System.Collection.Generic namespace represents a queue in C#, where T specifies the type of elements in the queue.
C# Hashtable:
A Hashtable is a collection of key/value pairs that are arranged based on the hash code of the key. Or in other words, a Hashtable is used to create a collection which uses a hash table for storage. It generally optimized the lookup by calculating the hash code of every key and store into another basket automatically and when you accessing the value from the hashtable at that time it matches the hashcode with the specified key. It is the non-generic type of collection which is defined in System.Collections namespace.
C# Dictionary:
In C#, Dictionary is a generic collection which is generally used to store key/value pairs. The working of Dictionary is quite similar to the non-generic hashtable. The advantage of Dictionary is, it is generic type. Dictionary is defined under System.Collections.Generic namespace. It is dynamic in nature means the size of the dictionary is grows according to the need.
C# Linked List:
A LinkedList is a linear data structure which stores element in the non-contiguous location. The elements in a linked list are linked with each other using pointers. Or in other words, LinkedList consists of nodes where each node contains a data field and a reference(link) to the next node in the list. In C#, LinkedList is the generic type of collection which is defined in System.Collections.Generic namespace.
Similar Reads
C# Program to Implement an Interface in a Structure Structure is a value type and a collection of variables of different data types under a single unit. It is almost similar to a class because both are user-defined data types and both hold a bunch of different data types. We can create a structure by using struct keyword. A structure can also hold co
2 min read
C# Data Structures Data Structures are an important part of programming language. When we are creating solutions for real-world problems, choosing the right data structure is critical because it can impact the performance of algorithms. If we know the fundamentals of data structures and know how to use them effectivel
15+ min read
Introduction to C# C# (C-sharp) is a modern, object-oriented programming language developed by Microsoft as part of the .NET framework. It was first released in 2000 and it has become one of the most widely used languages for building Windows applications, web services, and more. C# combines the power of C and C++ wit
7 min read
How to access structure elements using Pointers in C# Unlike C/C++, Structures in C# can have members that are methods, fields, indexers, operator methods, properties or events. The members can have access specifiers as public, private, and internal. Pointers are variables that store the addresses of the same type of variable i.e. an int pointer can st
3 min read
C# Program to Demonstrate the Static Constructor in Structure A Structure is a well-defined data structure that can hold elements of multiple data types. It is similar to a class because both are user-defined data types and both contain a bunch of different data types. You can also use pre-defined data types. However, sometimes the user might be in need to def
2 min read
C# | Generics - Introduction Generic is a class which allows the user to define classes and methods with the placeholder. Generics were added to version 2.0 of the C# language. The basic idea behind using Generic is to allow type (Integer, String, ⦠etc and user-defined types) to be a parameter to methods, classes, and interfac
6 min read