Click here to Skip to main content
15,912,205 members
Home / Discussions / C#
   

C#

 
QuestionString to Byte Conversion Pin
DavidMcP14-Feb-07 17:29
DavidMcP14-Feb-07 17:29 
AnswerRe: String to Byte Conversion Pin
stancrm14-Feb-07 20:09
stancrm14-Feb-07 20:09 
QuestionI am confiused and need your help with Windows Installer Pin
Khoramdin14-Feb-07 15:41
Khoramdin14-Feb-07 15:41 
AnswerRe: I am confiused and need your help with Windows Installer Pin
Syed Shahid Hussain14-Feb-07 18:27
Syed Shahid Hussain14-Feb-07 18:27 
QuestionLogin Class for C# Pin
allan.gagnon14-Feb-07 15:27
allan.gagnon14-Feb-07 15:27 
AnswerRe: Login Class for C# Pin
Christian Graus14-Feb-07 16:56
protectorChristian Graus14-Feb-07 16:56 
GeneralRe: Login Class for C# Pin
allan.gagnon15-Feb-07 3:17
allan.gagnon15-Feb-07 3:17 
GeneralRe: Login Class for C# Pin
Christian Graus15-Feb-07 8:10
protectorChristian Graus15-Feb-07 8:10 
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 

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.