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


Please Help Members By Posting Answers For Below Questions

What is serialization in .net?

972


If I want to override a method one of class A and in class b then how do you declare?

1286


Which attribute is used in order that the method can be used as webservice?

924


Give examples for value types?

935


Different between method overriding and method overloading?

968


To catch any possible exception What is the C# syntax written ?

976


What is difference between list and dictionary in c#?

859


What is indexer c#?

870


Explain how to use an extender provider in the project.

962


what will be the output of the given below coding. using System; public class Exercise { static void OddNumbers(int a) { if (a >= 1) { Console.Write("{0}, ", a); a -= 2; OddNumbers(a); } } public static int Main() { const int Number = 9; Console.WriteLine("Odd Numbers"); OddNumbers(Number); Console.WriteLine(); return 0; } }

4317


What is writeline in c#?

861


What is difference between private, protected, and public in C#?

1041


What is asynccallback c#?

1021


Explain About Global.asax

946


What are the fundamental oop concepts?

930