Click here to Skip to main content
15,903,012 members
Home / Discussions / C#
   

C#

 
GeneralRe: Nested foreach is a bad practice?(please read) Pin
teknolog12330-Oct-11 4:20
teknolog12330-Oct-11 4:20 
GeneralRe: Nested foreach is a bad practice?(please read) Pin
phil.o30-Oct-11 4:51
professionalphil.o30-Oct-11 4:51 
GeneralRe: Nested foreach is a bad practice?(please read) Pin
teknolog12330-Oct-11 4:59
teknolog12330-Oct-11 4:59 
GeneralRe: Nested foreach is a bad practice?(please read) Pin
BobJanova30-Oct-11 23:03
BobJanova30-Oct-11 23:03 
GeneralRe: Nested foreach is a bad practice?(please read) Pin
phil.o31-Oct-11 0:37
professionalphil.o31-Oct-11 0:37 
AnswerRe: Nested foreach is a bad practice?(please read) Pin
PIEBALDconsult30-Oct-11 5:54
mvePIEBALDconsult30-Oct-11 5:54 
GeneralRe: Nested foreach is a bad practice?(please read) Pin
teknolog12330-Oct-11 7:31
teknolog12330-Oct-11 7:31 
GeneralRe: Nested foreach is a bad practice?(please read) Pin
BillWoodruff30-Oct-11 19:14
professionalBillWoodruff30-Oct-11 19:14 
PIEBALDconsult wrote:
0.1.1) If they match, process the item, and advance both lists

0.1.2) If the first list's item is less than the second list's item, advance the first list
0.1.1 assumes a sorting (which you state is required) ... of the two lists ... but also assumes matching of items in each list so that you can be assured for each ith. entry in List 1, the ith. entry in List2 is what you need to compare. If List2, or List1 has 'intermediate,' or 'extra' values, this technique will clearly fail.

0.1.2 implies that the lists' items have some possible form of quantitative comparison possible (in this case using less-than) : this is not relevant to the scenario implied in this thread by the OP.

1, and 2. imply a possible difference in the length of the lists, which you say can be ignored here: but what happens if in the the part of list 2 (which is longer than list1) is an item that matches an item in list1 which you did not find a match for as you progressed sequentially ?

I'm not commenting on this from a 'picky-picky' perspective: I am generally curious as to why you think this 'schema' is broadly useful, or relevant to the OP's scenario, and I'd be even more curious as to how you actually used it recently.

Now that we have Linq, selecting items that match from Lists is a whole lot easier (if more difficult to master ... at least for me).

best, Bill
"Last year I went fishing with Salvador Dali. He was using a dotted
line. He caught every other fish." Steven Wright

GeneralRe: Nested foreach is a bad practice?(please read) Pin
PIEBALDconsult31-Oct-11 5:30
mvePIEBALDconsult31-Oct-11 5:30 
Answeriterate each list at most once Pin
Luc Pattyn31-Oct-11 7:20
sitebuilderLuc Pattyn31-Oct-11 7:20 
GeneralRe: iterate each list at most once Pin
PIEBALDconsult1-Nov-11 6:48
mvePIEBALDconsult1-Nov-11 6:48 
AnswerRe: Nested foreach is a bad practice?(please read) Pin
BillWoodruff30-Oct-11 18:43
professionalBillWoodruff30-Oct-11 18:43 
AnswerRe: Nested foreach is a bad practice?(please read) Pin
Luc Pattyn1-Nov-11 7:01
sitebuilderLuc Pattyn1-Nov-11 7:01 
GeneralRe: Nested foreach is a bad practice?(please read) Pin
Pete O'Hanlon1-Nov-11 8:08
mvePete O'Hanlon1-Nov-11 8:08 
QuestionHow set the background of an MDI container window? Pin
jojoba2029-Oct-11 1:17
jojoba2029-Oct-11 1:17 
AnswerRe: How set the background of an MDI container window? Pin
Philippe Mori29-Oct-11 3:16
Philippe Mori29-Oct-11 3:16 
AnswerRe: How set the background of an MDI container window? Pin
Dave Kreskowiak29-Oct-11 3:17
mveDave Kreskowiak29-Oct-11 3:17 
GeneralRe: How set the background of an MDI container window? Pin
BillWoodruff29-Oct-11 17:47
professionalBillWoodruff29-Oct-11 17:47 
GeneralRe: How set the background of an MDI container window? Pin
Dave Kreskowiak29-Oct-11 18:00
mveDave Kreskowiak29-Oct-11 18:00 
AnswerRe: How set the background of an MDI container window? Pin
BillWoodruff29-Oct-11 4:00
professionalBillWoodruff29-Oct-11 4:00 
AnswerRe: How set the background of an MDI container window? Pin
Alisaunder29-Oct-11 4:43
Alisaunder29-Oct-11 4:43 
AnswerRe: How set the background of an MDI container window? Pin
Luc Pattyn29-Oct-11 5:07
sitebuilderLuc Pattyn29-Oct-11 5:07 
GeneralRe: How set the background of an MDI container window? Pin
Dave Kreskowiak29-Oct-11 6:52
mveDave Kreskowiak29-Oct-11 6:52 
GeneralRe: How set the background of an MDI container window? Pin
Alisaunder29-Oct-11 10:52
Alisaunder29-Oct-11 10:52 
GeneralRe: How set the background of an MDI container window? Pin
Dave Kreskowiak29-Oct-11 14:24
mveDave Kreskowiak29-Oct-11 14:24 

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.