f i give input like 1,1,4,5,6,1,2,5,4,1,2, then output
should be like : 1-4, 2-2, 4-2, 5-1, 6-1 which means 1
occurs 4 times, 2 occurs 2 times like so.
Answer Posted / rajesh kardile
In C# 3.0 with Linq here how you will do
int[] intArray = { 1, 1, 4, 5, 6, 1, 2, 5, 4, 1, 2 };
var groups = from g in intArray
orderby g
group g by g;
StringBuilder stringBuilder = new StringBuilder();
foreach (var g in groups)
stringBuilder.Append(g.Key + "-" + g.Count() + ",");
Console.WriteLine(stringBuilder.ToString());
Is This Answer Correct ? | 1 Yes | 1 No |
Post New Answer View All Answers
What is asp net c#?
How jit (just in time) works?
What are the classes contained in a single .NET DLL ?
What is a data set in c#?
What language do desktop applications use?
What does void do in c#?
What is dynamic object in c#?
What is oledb in c#?
How many aware interfaces are there?
How do you concatenate in c#?
Why is hashset faster?
Why main is static in c#?
When a switch is said to be congested?
What does console readline do?
What is an assembly loader?