Hello! I'm trying out string.Split() for the first time and I'm very confused by my results. My input is a lot of lines like the following:
ILTOY46 310-410-21214-49860 WCHB1AX 0 0 0 1 IL05651 310-410-21209-5651 SCHB3AX 0 0 0 70 IL01737 310-410-21209-1737 SCHB3AX 0 0 0 38 IL05652 310-410-21209-5652 SCHB3AX 0 0 0 70 I want to split on a whitespace between each (and then trim off the extra whitespaces, but I'll worry about the string.Trim() when I get to it). My code looks like this: string[] MGCEP = new string[7]; MGCEP = searchLine.Split(); report.Text = MGCEP[0] + " " + MGCEP[1] + " " + MGCEP[2] + " " + MGCEP [3] + " " + MGCEP[4] + " " + MGCEP[5] + " " + MGCEP[6]; My output in the text box looks like this: ILTOY46 310-410-21214-49860 WCHB1AX 0 IL05651 310-410-21209-5651 SCHB3AX 0 IL01737 310-410-21209-1737 SCHB3AX 0 IL05652 310-410-21209-5652 SCHB3AX 0 What's happening to my last 3 elements? Why am I getting ILTOY46 310-410-21214-49860 WCHB1AX 0 instead of ILTOY46 310-410-21214-49860 WCHB1AX 0 0 0 1? Thank you for your help!
