Click here to Skip to main content
15,905,420 members
Home / Discussions / C#
   

C#

 
AnswerRe: code not being executed Pin
Guffa29-Jun-07 6:49
Guffa29-Jun-07 6:49 
GeneralRe: code not being executed Pin
Saamir29-Jun-07 9:16
Saamir29-Jun-07 9:16 
GeneralRe: code not being executed Pin
Luc Pattyn29-Jun-07 10:25
sitebuilderLuc Pattyn29-Jun-07 10:25 
AnswerRe: code not being executed Pin
Guffa29-Jun-07 12:10
Guffa29-Jun-07 12:10 
AnswerRe: code not being executed Pin
leppie29-Jun-07 4:48
leppie29-Jun-07 4:48 
AnswerRe: code not being executed Pin
Guffa29-Jun-07 6:38
Guffa29-Jun-07 6:38 
AnswerRe: code not being executed Pin
Martin#29-Jun-07 8:52
Martin#29-Jun-07 8:52 
GeneralRe: code not being executed Pin
Saamir29-Jun-07 9:12
Saamir29-Jun-07 9:12 
GeneralRe: code not being executed Pin
Martin#29-Jun-07 9:44
Martin#29-Jun-07 9:44 
GeneralRe: code not being executed Pin
Luc Pattyn29-Jun-07 9:14
sitebuilderLuc Pattyn29-Jun-07 9:14 
GeneralRe: code not being executed [modified] Pin
Martin#29-Jun-07 9:40
Martin#29-Jun-07 9:40 
GeneralRe: code not being executed Pin
Luc Pattyn29-Jun-07 10:16
sitebuilderLuc Pattyn29-Jun-07 10:16 
QuestionSense Open Excel Workbooks Pin
jeffbeagle29-Jun-07 4:01
jeffbeagle29-Jun-07 4:01 
QuestionActiveX Persistence in C# Pin
zam66429-Jun-07 3:58
zam66429-Jun-07 3:58 
QuestionCount Array Items with C# Pin
BenjaminMartin29-Jun-07 3:55
BenjaminMartin29-Jun-07 3:55 
AnswerRe: Count Array Items with C# Pin
Luc Pattyn29-Jun-07 4:28
sitebuilderLuc Pattyn29-Jun-07 4:28 
GeneralRe: Count Array Items with C# Pin
BenjaminMartin29-Jun-07 4:53
BenjaminMartin29-Jun-07 4:53 
GeneralRe: Count Array Items with C# Pin
leppie29-Jun-07 4:54
leppie29-Jun-07 4:54 
AnswerRe: Count Array Items with C# Pin
Guffa29-Jun-07 4:47
Guffa29-Jun-07 4:47 
AnswerRe: Count Array Items with C# Pin
leppie29-Jun-07 4:52
leppie29-Jun-07 4:52 
GeneralRe: Count Array Items with C# Pin
BenjaminMartin29-Jun-07 5:10
BenjaminMartin29-Jun-07 5:10 
AnswerRe: Count Array Items with C# Pin
Kevin McFarlane29-Jun-07 6:10
Kevin McFarlane29-Jun-07 6:10 
Apart from leppie's solution you might want to have a look at the free PowerCollections library.

PowerCollections[^]

Then you can do:

int[] array = new int[10];
array[0] = 1;
array[1] = 1;
array[2] = 1;
array[3] = 2;
array[4] = 1;
array[5] = 2;
array[6] = 1;
array[7] = 1;
array[8] = 2;
array[9] = 3;

int count1 = Algorithms.CountWhere(array, delegate(int i) { return i == 1; });
Console.WriteLine("Count = {0}", count1);
int count2 = Algorithms.CountWhere(array, delegate(int i) { return i == 2; });
Console.WriteLine("Count = {0}", count2);
int count3 = Algorithms.CountWhere(array, delegate(int i) { return i == 3; });
Console.WriteLine("Count = {0}", count3);


PowerCollections consists of additional data structures and algorithms, somewhat similar to C++'s STL. It's very easy to use. Just reference the DLL and add a using statement. It was written by a former member of the C# team and went though quite a lot of beta testing. There is another possibly more advanced library called C5, which I've never used.



Kevin

Questionndoc MSDN style document Pin
Software_Specialist29-Jun-07 3:36
Software_Specialist29-Jun-07 3:36 
AnswerRe: ndoc MSDN style document Pin
BoneSoft29-Jun-07 3:49
BoneSoft29-Jun-07 3:49 
GeneralRe: ndoc MSDN style document Pin
Software_Specialist29-Jun-07 3:54
Software_Specialist29-Jun-07 3:54 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.