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
Loading
VulpesPosted Nov 12, 2012, 8:18 AM
So, in the above program, you could replace:
return ia.Where(i => i == number).Count();
with simply this:
return ia.Count(i => i == number);
VulpesPosted Nov 13, 2012, 10:29 AM
Matt HigginsPosted Nov 13, 2012, 9:59 AM
I've just bought a book - I think I will get my next employer to treat me to one next or wait until Christmas. The books you recommend seem a little pricy which is the only obstacle.
I've also got an interview tomorrow for a c# developer position so I'm just keeping my fingers crossed for now.
Cheers
Matt
VulpesPosted Nov 13, 2012, 9:34 AM
However, there are several books which have helped me along the way. I'll single out a couple (latest versions) which I'd recommend any C# developer to read or to have available as a reference:
http://www.amazon.com/C-5-0-Nutshell-Definitive-Reference/dp/1449320104
http://www.amazon.com/CLR-via-C-Jeffrey-Richter/dp/0735627045
Matt HigginsPosted Nov 12, 2012, 11:54 AM
Can I ask - how did you become so good at programming? Is there any books or courses you've been on which really helped you along?
Cheers
Matt
VulpesPosted Nov 12, 2012, 8:12 AM