I know this is silly but i just want to use this kind of logic in one of the modules.
So I have a table in a datatable DTTest like shown below:-
And I wanted to loop through the dt such that if Nth row and (N-1) row data for Name matches then perform task ABC. Whereas If is not not matching, perform XYZ Task.
I was easily able to perform this logic.
for each row in DTTest:
if dtTest.Rows(index).Item(“Name”).ToString = dtTest.Rows(index-1).Item(“Name”).ToString
else (perform XYZ)
My problem: While this logic is working smoothly, I am getting index out of range error when we talk about the first row case ie (index=0) is being compared with (index - ‘-1’), which obviously goes out of range with respect to DT range.
Like if it is 1st row (index=0), then dont care about previous row
Please help me create a logic such that it handles the 1st row case too in my logic.
Thanks and Regards,