TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Joshua Chambers
NA
6
0
stumped on a good way to do something, ideas please!
May 16 2008 1:43 PM
So here's what I need to do... I have a set of results, and I need to tally how many times each result appears. If I were in PHP I would use a string indexed array, but I just don't know what kind of relatively elegant solution I can do in C#. I'm running through the results in a foreach loop. I've created a custom little class just to hold the data with, and I'm sure I'll need some kind of collection of them. The members are:
String name
int count
Each time through the loop, I need to search my collection of these and
if I already have one with a given name, increase the count. I just want someone to tell me there's a better way of doing this than ANOTHER foreach loop to loop through all the elements of the collection to compare the Strings to see if it exists already, cause that's about all I can think of. I'm pretty new to C#.
Any ideas are much appreaciated, thank you!
Joshua
Reply
Answers (
1
)
Keeps returning a negative to the binarysearch
Help with counting individual values in an array