LINQ makes this easy:
Dictionary<string, int> counts = array.GroupBy(x => x)
.ToDictionary(g => g.Key,
g => g.Count());
More Related Contents:
- C# foreach loop take values from outer loop to inner loop
- How to put char ('X') to int array?
- Ordered Unique Combinations [closed]
- C# appointing distinct array elements randomly to another array
- How to generate an Array of Double Arrays in c#? [duplicate]
- Define if statement for property in C# [closed]
- How to convert UTF-8 byte[] to string
- How to access random item in list?
- How to convert byte array to string [duplicate]
- Easiest way to compare arrays in C#
- What is the Maximum Size that an Array can hold?
- How do arrays in C# partially implement IList?
- Any faster way of copying arrays in C#?
- Comparing arrays in C#
- Find index of a value in an array
- Getting the “diff” between two arrays in C#?
- How to compare arrays in C#? [duplicate]
- Copy Arrays to Array
- Pick Random String From Array
- Random number generator in C# – unique values
- C# Permutation of an array of arraylists?
- Iterate through 2 dimensional array c#
- How to check if a byte array is a valid image?
- Why can’t I use the array initializer with an implicitly typed variable?
- convert string array to string
- How can I safely convert a byte array into a string and back? [duplicate]
- Why do arrays in .net only implement IEnumerable and not IEnumerable?
- Using XmlSerializer with an array in the root element
- Is string actually an array of chars or does it just have an indexer?
- byte[] to BitmapImage in silverlight