Click here to Skip to main content
15,887,267 members
Home / Discussions / C#
   

C#

 
GeneralRe: Understanding Jagged Arrays Pin
N8tiv20-May-13 4:00
N8tiv20-May-13 4:00 
GeneralRe: Understanding Jagged Arrays Pin
Richard Deeming20-May-13 4:19
mveRichard Deeming20-May-13 4:19 
GeneralRe: Understanding Jagged Arrays Pin
Richard MacCutchan20-May-13 5:12
mveRichard MacCutchan20-May-13 5:12 
GeneralRe: Understanding Jagged Arrays Pin
N8tiv20-May-13 6:04
N8tiv20-May-13 6:04 
GeneralRe: Understanding Jagged Arrays Pin
Richard MacCutchan20-May-13 7:19
mveRichard MacCutchan20-May-13 7:19 
GeneralRe: Understanding Jagged Arrays Pin
N8tiv20-May-13 7:30
N8tiv20-May-13 7:30 
GeneralRe: Understanding Jagged Arrays Pin
Matt T Heffron20-May-13 8:49
professionalMatt T Heffron20-May-13 8:49 
GeneralRe: Understanding Jagged Arrays Pin
Richard MacCutchan20-May-13 22:26
mveRichard MacCutchan20-May-13 22:26 
WidmarkRob wrote:
is my verbiage all wrong?
Not really, perhaps, my understanding was. Your question (I think) is about where to declare the loop variable. It is largely a question of where the variable is to be used. Consider the following code:
C#
// first sample
int index;
for (index = 0; index < someValue; ++index)
{
    // do some stuff here
}
if (index == someOtherValue)
// ... at this point we can use the final value of the variable because it
//     was declared outside of the for statement.


// second sample
for (int index = 0; index < someValue; ++index)
{
    // do some stuff here
}
if (index == someOtherValue)  // ERROR
// ... at this point we cannot use the final value of the variable because it
//     was declared inside the for statement, and does not exist outside the loop.
// i.e the scope of the variable is within the for statement and its block, bounded
// by the curly braces.

Use the best guess

GeneralRe: Understanding Jagged Arrays Pin
N8tiv23-May-13 15:24
N8tiv23-May-13 15:24 
GeneralRe: Understanding Jagged Arrays Pin
Richard MacCutchan23-May-13 20:42
mveRichard MacCutchan23-May-13 20:42 
GeneralRe: Understanding Jagged Arrays Pin
N8tiv23-May-13 21:15
N8tiv23-May-13 21:15 
GeneralRe: Understanding Jagged Arrays Pin
Richard MacCutchan23-May-13 22:22
mveRichard MacCutchan23-May-13 22:22 
GeneralRe: Understanding Jagged Arrays Pin
Jasmine250120-May-13 10:44
Jasmine250120-May-13 10:44 
GeneralRe: Understanding Jagged Arrays Pin
N8tiv20-May-13 10:47
N8tiv20-May-13 10:47 
GeneralRe: Understanding Jagged Arrays Pin
Jasmine250120-May-13 10:52
Jasmine250120-May-13 10:52 
GeneralRe: Understanding Jagged Arrays Pin
N8tiv20-May-13 10:57
N8tiv20-May-13 10:57 
GeneralRe: Understanding Jagged Arrays Pin
N8tiv20-May-13 11:06
N8tiv20-May-13 11:06 
GeneralRe: Understanding Jagged Arrays Pin
Jasmine250120-May-13 11:18
Jasmine250120-May-13 11:18 
GeneralRe: Understanding Jagged Arrays Pin
N8tiv20-May-13 12:00
N8tiv20-May-13 12:00 
GeneralRe: Understanding Jagged Arrays Pin
Jasmine250120-May-13 12:47
Jasmine250120-May-13 12:47 
GeneralRe: Understanding Jagged Arrays Pin
N8tiv20-May-13 13:04
N8tiv20-May-13 13:04 
GeneralRe: Understanding Jagged Arrays Pin
Jasmine250120-May-13 13:31
Jasmine250120-May-13 13:31 
GeneralRe: Understanding Jagged Arrays Pin
N8tiv20-May-13 13:41
N8tiv20-May-13 13:41 
GeneralRe: Understanding Jagged Arrays Pin
N8tiv23-May-13 21:17
N8tiv23-May-13 21:17 
Questioncounting in c# Pin
MKS Khalid20-May-13 0:50
MKS Khalid20-May-13 0: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.