Click here to Skip to main content
16,014,392 members
Home / Discussions / C#
   

C#

 
GeneralThe current index in the foreach Pin
cazzz27-Jul-05 10:32
cazzz27-Jul-05 10:32 
GeneralRe: The current index in the foreach Pin
jan larsen27-Jul-05 10:49
jan larsen27-Jul-05 10:49 
GeneralRe: The current index in the foreach Pin
cazzz27-Jul-05 11:01
cazzz27-Jul-05 11:01 
GeneralRe: The current index in the foreach Pin
Judah Gabriel Himango27-Jul-05 11:10
sponsorJudah Gabriel Himango27-Jul-05 11:10 
GeneralRe: The current index in the foreach Pin
Matt Gerrans27-Jul-05 12:55
Matt Gerrans27-Jul-05 12:55 
GeneralRe: The current index in the foreach Pin
Judah Gabriel Himango27-Jul-05 13:49
sponsorJudah Gabriel Himango27-Jul-05 13:49 
GeneralRe: The current index in the foreach Pin
jan larsen27-Jul-05 20:57
jan larsen27-Jul-05 20:57 
GeneralRe: The current index in the foreach Pin
jan larsen27-Jul-05 11:13
jan larsen27-Jul-05 11:13 
foreach is great when you're abstracting your code. Indexing is purely for lists, and if you're doing a foreach on an IEnumerable, then you're always sure to get the maximum performance. Consider the performance issues on indexing eg. a linked list or a binary tree.
I'm always declaring my collection member variables as the lowest denominator. Eg. if I need a map, then I'm declaring an IDictionary, and when I'm iterating through the elements, I'll use a foreach loop.
This means that if I am to use a counter, then I have to do it the ugly way.

"God doesn't play dice" - Albert Einstein

"God not only plays dice, He sometimes throws the dices where they cannot be seen" - Niels Bohr
GeneralRe: The current index in the foreach Pin
Libor Tinka27-Jul-05 11:44
Libor Tinka27-Jul-05 11:44 
GeneralRe: The current index in the foreach Pin
jan larsen27-Jul-05 20:38
jan larsen27-Jul-05 20:38 
GeneralRe: The current index in the foreach Pin
Patric_J28-Jul-05 4:47
Patric_J28-Jul-05 4:47 
GeneralRe: The current index in the foreach Pin
jan larsen28-Jul-05 8:02
jan larsen28-Jul-05 8:02 
Generaltextbox processed by enter key Pin
Anonymous27-Jul-05 10:20
Anonymous27-Jul-05 10:20 
GeneralRe: textbox processed by enter key Pin
Alomgir Miah27-Jul-05 10:30
Alomgir Miah27-Jul-05 10:30 
GeneralRe: textbox processed by enter key Pin
Anonymous27-Jul-05 10:48
Anonymous27-Jul-05 10:48 
GeneralRe: textbox processed by enter key Pin
jan larsen27-Jul-05 10:59
jan larsen27-Jul-05 10:59 
GeneralRe: textbox processed by enter key Pin
Guffa27-Jul-05 11:00
Guffa27-Jul-05 11:00 
Generalomg, what a cry baby! Pin
Anonymous27-Jul-05 11:45
Anonymous27-Jul-05 11:45 
GeneralRe: omg, what a cry baby! Pin
Guffa27-Jul-05 23:59
Guffa27-Jul-05 23:59 
QuestionHow can I.. Pin
KORCARI27-Jul-05 9:54
KORCARI27-Jul-05 9:54 
AnswerRe: How can I.. Pin
Alomgir Miah27-Jul-05 10:32
Alomgir Miah27-Jul-05 10:32 
GeneralRegular Expression Pin
eggie527-Jul-05 9:47
eggie527-Jul-05 9:47 
GeneralRe: Regular Expression Pin
Dan Neely27-Jul-05 10:38
Dan Neely27-Jul-05 10:38 
GeneralRe: Regular Expression Pin
Werdna27-Jul-05 11:13
Werdna27-Jul-05 11:13 
GeneralInheritance instances Pin
zapap27-Jul-05 9:31
zapap27-Jul-05 9:31 

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.