Friends, good afternoon! I have the following problem, before I used a "FOR" code in the meantime, to improve the performance of the application, I had to change my code to work with lines using DataRow, however, when working with foreach I can not plus grab the index value from my line. I have a excel sheet that I need to get index 6, because line 1 to 5 is header, however I tried to create several ways to create a counter, but take index 1 and not index 6 forward that would be correct. Could someone please help me?
when I used my "FOR" I could read line A6 ahead and the other columns:
- for (int i = 5; i <(numberLines - 1); i ++)
- {
- if (process! = null)
- {
-
- List <ProcessInterest> listprocinter = ProcessInterested.consultProcessor (process.Code);
- if (listprocinter.Exists (o => o.interest == interested))
-
- log.Append ("The interested" + process.Interested.Name + ", entered in the line" + (i + 1) + "was added again to the process" + process.NumProcesso + "");
-
-
- setProcInter (process, interested, ds, row);
- }
- else
- {
-
- process = new Process ();
- }
- }
However, to improve performance I had to implement the foreach in place of the "FOR" and work with the DataRow and line. This is my changed code, but I can not get the index more correctly, can you please help me?
- foreach (var line in (IEnumerable <DataRow>) data)
- {
- if (process! = null)
- {
-
- List <ProcessInterest> listprocinter = ProcessInterested.consultProcessor (process.Code);
- if (listprocinter.Exists (o => o.interest == interested))
-
- log.Append ("The interested" + process.Interested.Name + ", entered in the line" + (i + 1) + "was added again to the process" + process.NumberProcess + "");
-
-
- setProcInter (process, interested, ds, row);
- }
- else
- {
-
- process = new Process ();
- process.Interested = interested;
- }
- }