Quantcast
Channel: Collection – Abundant Code
Browsing all 10 articles
Browse latest View live

How to update the value in a Dictionary in C# ?

Below is a sample code snippet demonstrating how to update the value that is stored within the dictionary using C#. We access the dictionary with the key as index and set the value. How to update the...

View Article



How to convert List to string with comma delimiter in C# ?

If you need to convert a collection (for example List of string) to string separated with the Comma as delimiter , you can either use the string.join method or aggregate method as shwon below. How to...

View Article

How to Get the Top 5 elements from a List in C# ?

If you want to get the top 5 elements from a list in C# or skip the first item and get the next five elements from a List , you can use the Take and the Skip methods. How to Get the Top 5 elements from...

View Article

How to Get the Dictionary Key by value in C# ?

If you want to get the Key of a dictionary based on the value in C# , you can use the LINQ’s where clause o FirstOrDefault method. How to Get the Dictionary Key by value in C# ? using System; using...

View Article

How to Add item to the beginning of List in C# ?

If you want to add or insert an item to the beginning of the List in C# , you can use the Insert method defined in the collection as shown below. How to Add item to the beginning of List in C# ? using...

View Article


How to make a Type Sortable on Different Criteria in C# ?

IComparable interface is a great way to sort your objects by using the sorting routines of the List. There is a another interface called IComparer<T> which allows the objects to be sorted based...

View Article

Using HashSet to remove duplicates from array in C#

If you want to remove duplicates from an array in C# , one of the options is to use HashSet as shown below. How to remove duplicates from an array in C# using HashSet?   using System; using...

View Article

How to Check if the ArrayList is read-only in C# ?

There are times when you would use the read-only wrapper in order to prevent modifying the ArrayList. We use the ArrayList.ReadOnly method to create such collection. When doing so , you might want to...

View Article


How to Get the number of elements in ArrayList in C# ?

Here’s the code that demonstrates how one can get the total number of elements contained in the ArrayList using C# using the Count property of the ArrayList. How to Get the number of elements in...

View Article


How to Create an Empty array without defining the size in C# ?

When we create an array in C# , we tend to define the size of the array as shown below. String[] strArray = new String[5]; Can we create an array without defining the size ? The best option in this...

View Article
Browsing all 10 articles
Browse latest View live




Latest Images