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
Lepre
NA
1
1.9k
c# print out number of sellers per level
Oct 26 2012 10:31 PM
Hi! I'm very new to C# and is having a bit of a loop problem. At the moment I have a group of sellers that needs to be counted by the amount of articles sold. They are already assigned to their respective level by the following conditions: if (seller[i].articles < 50) seller[i].level = 1; if (seller[i].articles >= 50 && seller[i].articles < 100) seller[i].level = 2; if (seller[i].articles >= 100 && seller[i].articles < 200) seller[i].level = 3; if (seller[i].articles >= 200) seller[i].level = 4; However, a slight problem arises when I want to count how many of the sellers that actually are in respective level. This might lend a clue to figure out what I'm trying to achieve: int count = 0; for (int i = 0; i < 3; i++) { if (seller[i].level == i) count++; Console.WriteLine("Numbers of sellers in level {0}: {1}", seller[i].level, count); } Regards, L
Reply
Answers (
1
)
C# string replace
C# Console Loop Control