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
How do you determine whether a string represents a numeric value?
Are constructors inherited c#?
What is generic method in c#?
What is difference between array and arraylist c#?
What is the difference between early binding and late binding in c#?
Can you have parameters for static constructors?
What is class sortedlist underneath?
Can structs in c# have destructors?
4. Describe the process when we send a request URL? And who is responsible for that?
Explain About Virtual functions and their use.
What is object type in c#?
What are the characteristics of c#?
Define the term immutable ?
What is interface used in c#?
What is anonymous types in c#?