Click here to Skip to main content
15,867,453 members
Home / Discussions / C#
   

C#

 
GeneralRe: can u help me with a if question? Pin
andredani6-Sep-07 0:32
andredani6-Sep-07 0:32 
GeneralRe: can u help me with a if question? Pin
TJoe6-Sep-07 1:58
TJoe6-Sep-07 1:58 
GeneralRe: can u help me with a if question? Pin
andredani6-Sep-07 3:08
andredani6-Sep-07 3:08 
GeneralRe: can u help me with a if question? Pin
TJoe6-Sep-07 3:15
TJoe6-Sep-07 3:15 
GeneralRe: can u help me with a if question? [modified] Pin
andredani6-Sep-07 3:34
andredani6-Sep-07 3:34 
GeneralRe: can u help me with a if question? Pin
TJoe6-Sep-07 3:40
TJoe6-Sep-07 3:40 
GeneralRe: can u help me with a if question? Pin
andredani6-Sep-07 4:02
andredani6-Sep-07 4:02 
GeneralRe: can u help me with a if question? Pin
TJoe6-Sep-07 5:29
TJoe6-Sep-07 5:29 
Based on the example above, the code below will properly parse it out. I included comments so that you can understand what it's doing and learn from it. But, if you have an questions then let me know.

// This index will point to the current line and will start with
//   the first line.
Int32 index = 0;

// We want to loop while there are valid blocks. This means that
//   if our index is pointing to the first line, then there must
//   be atleast 6 lines left (one for each item in the block).
while (lines.Length >= index + 6) {
    // At this point we know that index should point to the start
    //   of a block. We also know that there are atleast 5 more
    //   lines beyond the current line (e.g. the one pointed to
    //   by index).
    //

    // Make sure that the block starts with a #, if not then we
    //   will skip this line and contine the loop. This means
    //   that if there is some extras lines after a block (either
    //   blank or just junk), then we will skip them.
    if ("#" != lines[index].Trim()) {
        // It's not a #, so it's a bad line we will skip it by
        //   incrementing the index, then start the loop again
        //   and hopefully this time we will be at the start of
        //   a valid block.
        index++;
        continue;
    }

    // The current line is a valid block indicator and we know
    //   that the 5 other pieces of information are available
    //   in the lines variable. So pull them out.
    String name1 = lines[index + 1];
    String path1 = lines[index + 2];
    String path2 = lines[index + 3];
    String price = lines[index + 4];
    String name2 = lines[index + 5];

    // Now we can skip over the lines we just read, which should
    //   move us to the next block.
    index += 6;

    // TODO: Do something with this information.
}


Take care,
Tom

-----------------------------------------------
Check out my blog at http://tjoe.wordpress.com

GeneralRe: can u help me with a if question? Pin
andredani6-Sep-07 11:25
andredani6-Sep-07 11:25 
GeneralRe: can u help me with a if question? Pin
TJoe7-Sep-07 2:15
TJoe7-Sep-07 2:15 
GeneralRe: can u help me with a if question? Pin
andredani7-Sep-07 2:54
andredani7-Sep-07 2:54 
GeneralRe: can u help me with a if question? Pin
TJoe7-Sep-07 3:12
TJoe7-Sep-07 3:12 
GeneralRe: can u help me with a if question? Pin
andredani7-Sep-07 5:13
andredani7-Sep-07 5:13 
AnswerRe: can u help me with a if question? Pin
Luc Pattyn5-Sep-07 9:59
sitebuilderLuc Pattyn5-Sep-07 9:59 
GeneralRe: can u help me with a if question? [modified] Pin
andredani5-Sep-07 11:31
andredani5-Sep-07 11:31 
QuestionWorkaround global variables? Pin
MeLight5-Sep-07 8:36
MeLight5-Sep-07 8:36 
AnswerRe: Workaround global variables? Pin
TJoe5-Sep-07 8:52
TJoe5-Sep-07 8:52 
AnswerRe: Workaround global variables? Pin
Christian Graus5-Sep-07 8:53
protectorChristian Graus5-Sep-07 8:53 
AnswerRe: Workaround global variables? Pin
Larantz5-Sep-07 8:53
Larantz5-Sep-07 8:53 
AnswerThanx Pin
MeLight5-Sep-07 8:57
MeLight5-Sep-07 8:57 
AnswerRe: Workaround global variables? Pin
Dave Kreskowiak5-Sep-07 9:08
mveDave Kreskowiak5-Sep-07 9:08 
Questionsizeof Pin
dino20945-Sep-07 8:26
dino20945-Sep-07 8:26 
AnswerRe: sizeof Pin
TJoe5-Sep-07 8:50
TJoe5-Sep-07 8:50 
GeneralRe: sizeof Pin
Luc Pattyn5-Sep-07 10:02
sitebuilderLuc Pattyn5-Sep-07 10:02 
GeneralRe: sizeof Pin
TJoe5-Sep-07 10:19
TJoe5-Sep-07 10:19 

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.