Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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 / amitabh dubey

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 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is icollection in c#?

858


What is the difference between struct and class c#?

926


What is main thread in c#?

860


Explain the functionalities of satellite assembly?

904


What is equal c#?

871


How many bytes is a char c#?

836


Is null empty or whitespace c#?

908


How does insertion sort work?

872


What is msil, and why should developers need an appreciation of it if at all?

985


Explane each and every methods of nterface Queue? Explain About performance issues on retrieving records

999


What is the meaning of MSIL?

1161


What are "class access modifiers" in C#?

898


Explain the mechanism of VB.NET/C# achieve polymorphism?

942


Why linq is having select clause at the end?

868


What is the use of return in c#?

887