![]() |
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:
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:
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. 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. |
Reffered: https://www.geeksforgeeks.org
Data Structures |
Type: | Geek |
Category: | Coding |
Sub Category: | Tutorial |
Uploaded by: | Admin |
Views: | 15 |