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
Matt Higgins
NA
32
24.6k
Is there an array method to return the how many elements are a value of 1?
Nov 12 2012 7:51 AM
Hi
With c# the array Max, Min and Average Methods are brilliant for working out those things as needs.
But also does anyone know if there is an array method that tells you the number of elements that are equal to a certain value.
For example, I've written a little app which computes the number of times it will takes to get 3 in a line when playing a slot machine. So far, I've found that it would take an average 80 attempts to hit a jackpot.
Out of curiosity I would like to know how many elements of my array are equal to one. In other words, this would mean that someone has got two Jackpots in a row!! I've seen it done quite a few times!!
Anyway, does anyone know if there is an array method that tells you the number of elements that are equal to a certain value? for example, how many array elements are equal to 1.
cheers
Matt
Reply
Answers (
6
)
When and when not to use the ToString() method
Homepage? database?