I want to just exit from the loop, I m facing the probs,see bolded part...
protected void btnSellProduct_Click(object sender, EventArgs e)
{
string sPath = Server.MapPath("~/");
string sFileName = sPath + "item.txt";
string[] sArr;
string[] sArr2;
int lCount;
int lCurrentStock;
int lSellingStock;
if (File.Exists(sFileName.Trim()) == true)
{
sArr = System.IO.File.ReadAllLines(sFileName);
for (lCount =0;lCount <= sArr.Length -1; lCount ++)
{
sArr2 = sArr[lCount].Split(new string[] { "^^^^" }, StringSplitOptions.None);
if (sArr2[0].Trim() == txtSellProdID.Text.Trim())
[B] // Once Control go inside this condition,i want to exit from the for loop. For Dat
// i Write break,but
//for (lCount =0;lCount <= sArr.Length -1; lCount ++)
// in the above line , lCount ++ is underline - Unreachable code detected.[/B]
{
lCurrentStock = Convert.ToInt32(sArr2[3]);
lSellingStock = Convert.ToInt32(txtQtyToSold.Text);
if (lSellingStock > lCurrentStock)
lblStatus.Text = "Could not Sell this Product.Out of Stock";
else
{
WriteToTransactionFile();
DecrementFromItemFile();
lblStatus.Text = "Transaction Processed Successfully";
}
}
break;
}
}
}