Click here to Skip to main content
15,899,126 members
Home / Discussions / C#
   

C#

 
GeneralRe: Login Class for C# Pin
allan.gagnon15-Feb-07 8:45
allan.gagnon15-Feb-07 8:45 
QuestionGirdview Template field problem Pin
SharonRao14-Feb-07 13:42
SharonRao14-Feb-07 13:42 
QuestionStartup - Triggering events Pin
Glen Harvy14-Feb-07 12:56
Glen Harvy14-Feb-07 12:56 
AnswerRe: Startup - Triggering events Pin
Luc Pattyn14-Feb-07 14:59
sitebuilderLuc Pattyn14-Feb-07 14:59 
QuestionMaking a count of unique elements in an array Pin
TrooperIronMan14-Feb-07 12:34
TrooperIronMan14-Feb-07 12:34 
AnswerRe: Making a count of unique elements in an array Pin
Luc Pattyn14-Feb-07 12:43
sitebuilderLuc Pattyn14-Feb-07 12:43 
GeneralRe: Making a count of unique elements in an array Pin
TrooperIronMan14-Feb-07 14:28
TrooperIronMan14-Feb-07 14:28 
GeneralRe: Making a count of unique elements in an array Pin
Luc Pattyn14-Feb-07 14:54
sitebuilderLuc Pattyn14-Feb-07 14:54 
Hi,

I did not laugh, but I was amazed about the complexity you introduced.
Will you ever feel sure this is correct ??

Some detailed remarks:
1) your code can handle no more than 5 objects, there is no need for such a limitation
2) I did not like the name "o" for one of the objects; I avoid single-character names
except maybe for local int counters; for real objects, I use real names.
3) you did the first object outside the for loop, then needed extra stuff
(passcount>0) to skip it inside the loop; better do everything inside the loop

But in the end, you followed the approach I suggested.

Did you realize you are relying on the fact that ArrayList preserves the order
of the elements added (unless you instruct it otherwise, e.g. Sort) ?

When using a hashtable, you dont need such assumption: it is intended to keep
key,value pairs together (as opposed to your code trying to keep an ArrayList and
an int array in the same order).

The test you need is Hashtable.Contains()

May I suggest you take some time to read up on collections (mainly ArrayList
and Hashtable). They are powerful tools that can be applied on many occasions,
requiring less code (and hence offering less room for bugs).

Regards.



Luc Pattyn

GeneralRe: Making a count of unique elements in an array Pin
TrooperIronMan15-Feb-07 3:32
TrooperIronMan15-Feb-07 3:32 
GeneralRe: Making a count of unique elements in an array Pin
Guffa14-Feb-07 15:11
Guffa14-Feb-07 15:11 
GeneralRe: Making a count of unique elements in an array Pin
TrooperIronMan15-Feb-07 13:22
TrooperIronMan15-Feb-07 13:22 
QuestionFlash video files Pin
alostdruid14-Feb-07 11:18
alostdruid14-Feb-07 11:18 
QuestionSerial Communication using SerialDataReceivedEventHandler Pin
cocoonwls14-Feb-07 10:42
cocoonwls14-Feb-07 10:42 
QuestionCreate report ... Word / pdf or new form Pin
Rick van Woudenberg14-Feb-07 10:15
Rick van Woudenberg14-Feb-07 10:15 
AnswerRe: Create report ... Word / pdf or new form Pin
cocoonwls14-Feb-07 10:27
cocoonwls14-Feb-07 10:27 
QuestionCollection of objects Pin
Wayne Phipps14-Feb-07 9:38
Wayne Phipps14-Feb-07 9:38 
AnswerRe: Collection of objects Pin
Guffa14-Feb-07 11:30
Guffa14-Feb-07 11:30 
QuestionEscaping special characters in SQL Statement after form submission Pin
dboy22114-Feb-07 9:30
dboy22114-Feb-07 9:30 
AnswerRe: Escaping special characters in SQL Statement after form submission Pin
Wayne Phipps14-Feb-07 9:48
Wayne Phipps14-Feb-07 9:48 
AnswerRe: Escaping special characters in SQL Statement after form submission Pin
Abisodun14-Feb-07 9:55
Abisodun14-Feb-07 9:55 
Questionparsing dicom file Pin
rajuhero14-Feb-07 9:06
rajuhero14-Feb-07 9:06 
AnswerRe: parsing Pin
Colin Angus Mackay14-Feb-07 9:10
Colin Angus Mackay14-Feb-07 9:10 
QuestionHow to create folder by C#? Pin
abalbo14-Feb-07 8:53
abalbo14-Feb-07 8:53 
AnswerRe: How to create folder by C#? Pin
Stefan Troschuetz14-Feb-07 9:00
Stefan Troschuetz14-Feb-07 9:00 
AnswerRe: How to create folder by C#? Pin
MaxRelaxman14-Feb-07 9:04
MaxRelaxman14-Feb-07 9:04 

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.