I writing a line item and the values are like this
Ad# Pub# Loc date line#
ad1 P001 AK 093010 1
ad1 P001 AK 093010 2
ad1 P001 AK 093010 3
ad1 P001 AK 100110 1
When the ad#,Pub#, loc and date are same as the previous record the line is incremented. Once any of the values in ad,pub, loc and date changes compared to previous record value of line is changed to 1 again. I am writing these lines in a for loop. I need to know what logic i need to use to get the line# values? Do i use an array to store values of previous line in an array and compare them with current line values and if they are same then add 1 to line#. Is there a better logic? Or is there a better way other than arrays to compare the previous line and current line
These values are got in from various tables.
for (int l=0;l<totalrecords;l++)
{
for (int i=0 ;i<fields.Length;i++)
{
if (i==0)
{
// logic to get the value for field 1
}
else if (i==1)
{
// logic to get the value for field 2
}
if (i==3)
{
// logic to get the value for field 3
}
else if (i==4)
{
// logic to get the value for field 4
}
else if (i==5)
{
// What would be the logic to write the line#???
}
}
}
thanks Prady