Click here to Skip to main content
16,004,898 members
Home / Discussions / C#
   

C#

 
QuestionCheck Children in MDIParent Pin
Socheat.Net25-Nov-09 16:15
Socheat.Net25-Nov-09 16:15 
AnswerRe: Check Children in MDIParent Pin
N a v a n e e t h25-Nov-09 16:34
N a v a n e e t h25-Nov-09 16:34 
GeneralRe: Check Children in MDIParent Pin
Socheat.Net25-Nov-09 17:08
Socheat.Net25-Nov-09 17:08 
GeneralRe: Check Children in MDIParent Pin
N a v a n e e t h25-Nov-09 17:11
N a v a n e e t h25-Nov-09 17:11 
AnswerRe: Check Children in MDIParent Pin
dan!sh 25-Nov-09 16:58
professional dan!sh 25-Nov-09 16:58 
GeneralRe: Check Children in MDIParent Pin
Socheat.Net25-Nov-09 17:17
Socheat.Net25-Nov-09 17:17 
QuestionArray Help Pin
Joe Spaz25-Nov-09 14:06
Joe Spaz25-Nov-09 14:06 
AnswerRe: Array Help Pin
Luc Pattyn25-Nov-09 14:29
sitebuilderLuc Pattyn25-Nov-09 14:29 
Hi,

I think it has to be Convert.ToString(intZip[intcounter,1]); to correspond to the conditional test on the line before it.

However there are better ways to do this:

1.
an array is fine when you know the number of elements in advance; otherwise you should use a list (good old ArrayList, or better yet the generic List<T> where T is some type).

2.
using a two-dimensional array like this is a little ugly. A clearer (but more expensive) way would be to create a class or struct that holds one ZIP code and one shipping quantity, then build a one-dimensional array or a generic list of such elements.

3.
and then, as you are interested in mapping one collection (ZIP codes) onto another collection (quantities), there is even better; have a look at the generic Dictionary<TKey,TValue> class. Using that, with its indexing capabilities and its Find methods, you could eliminate your for loop entirely.

4.
and finally some people will argue your data belongs in a database table, so you don't need a Dictionary, a simple SQL query would come up with the result.

PS: you have a strange return inside the if-else; I would expect both cases to be more similar, i.e. have
a return after the if-else (or none at all, if that's the end of the method).

Smile | :)

Luc Pattyn [Forum Guidelines] [My Articles]

I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages


AnswerRe: Array Help Pin
_Maxxx_25-Nov-09 14:33
professional_Maxxx_25-Nov-09 14:33 
AnswerRe: Array Help Pin
Joe Spaz25-Nov-09 14:42
Joe Spaz25-Nov-09 14:42 
QuestionParallel Extensions Pin
427748025-Nov-09 12:17
427748025-Nov-09 12:17 
AnswerRe: Parallel Extensions Pin
Nicholas Butler25-Nov-09 21:32
sitebuilderNicholas Butler25-Nov-09 21:32 
QuestionWeb authentication by code Pin
ika225-Nov-09 11:12
ika225-Nov-09 11:12 
AnswerRe: Web authentication by code Pin
Mycroft Holmes25-Nov-09 13:24
professionalMycroft Holmes25-Nov-09 13:24 
GeneralRe: Web authentication by code Pin
ika225-Nov-09 23:41
ika225-Nov-09 23:41 
QuestionUser Feedback while main thread is busy Pin
User 260419325-Nov-09 9:47
User 260419325-Nov-09 9:47 
AnswerRe: User Feedback while main thread is busy Pin
Luc Pattyn25-Nov-09 10:23
sitebuilderLuc Pattyn25-Nov-09 10:23 
GeneralRe: User Feedback while main thread is busy Pin
Mycroft Holmes25-Nov-09 13:31
professionalMycroft Holmes25-Nov-09 13:31 
GeneralRe: User Feedback while main thread is busy Pin
Luc Pattyn25-Nov-09 14:16
sitebuilderLuc Pattyn25-Nov-09 14:16 
GeneralRe: User Feedback while main thread is busy Pin
Mycroft Holmes25-Nov-09 14:30
professionalMycroft Holmes25-Nov-09 14:30 
GeneralRe: User Feedback while main thread is busy Pin
Luc Pattyn25-Nov-09 14:45
sitebuilderLuc Pattyn25-Nov-09 14:45 
GeneralRe: User Feedback while main thread is busy Pin
Mycroft Holmes25-Nov-09 14:55
professionalMycroft Holmes25-Nov-09 14:55 
GeneralRe: User Feedback while main thread is busy {modified} Pin
Luc Pattyn25-Nov-09 15:02
sitebuilderLuc Pattyn25-Nov-09 15:02 
GeneralRe: User Feedback while main thread is busy {modified} Pin
N a v a n e e t h25-Nov-09 16:32
N a v a n e e t h25-Nov-09 16:32 
GeneralRe: User Feedback while main thread is busy {modified} Pin
Luc Pattyn25-Nov-09 16:50
sitebuilderLuc Pattyn25-Nov-09 16:50 

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.