why this not incremention....rectidy error

Posted by Oswaldlily under C# on 11/30/2011 | Points: 10 | Views : 901 | Status : [Member] | Replies : 1
List<values> listvalue = new List<values>();
int t=0;
int m = 0;
int p = 0;
values value = new values();
while(p < data.Length - 1)
{

if (splitdata[p].Contains("ABC"))
{
pno = splitdata[p].Substring(42, 11);
pn=Convert.ToInt32(pno);
value.partno = pn.ToString();
while (m < data.Length - 1)
{
if (splitdata[m].Contains("DEF"))
{
mno = splitdata[m].Substring(42, 11);
mn=Convert.ToInt32(mno);
value.matno=mn.ToString();
while (t < data.Length - 1)
{
if (splitdata[t].Contains("GHI "))
{
sno = splitdata[t].Substring(42, 11);
sn = Convert.ToSingle(sno);
value.thickness = sn.ToString();
}
t=t+1;
}
}
m = m + 1;
}
listvalue.Add(value);
}
p = p + 1;
}

here "p" value alone incrementing in listvalue..
m and t gives last value..not incrementing.y?




Responses

Posted by: Blessyjees on: 12/1/2011 [Member] Bronze | Points: 25

Up
0
Down
Hi,

Where you get the value of m and t as last value, after P=P+1? if yes, these values are incremented in a separate while loop. THe excution goes out only finish the loop. So we get last value of these variables outside the loop.

Blessy Baby
Digitalmesh Softech pvt Ltd
https://blessybaby.wordpress.com/

Oswaldlily, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response