It is used on a collection and returns each element in order.
->foreach & for loop same work or function(print) but incase of foreach we can't modify in future .
->foreach & for loop same work or function(print) but incase of foreach we can't modify in future .
sample code:
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
int[] marks = new int[] { 60, 70, 80 };
foreach(int s in marks)
{
protected void Page_Load(object sender, EventArgs e)
{
int[] marks = new int[] { 60, 70, 80 };
foreach(int s in marks)
{
Response.Write(s);
}
}
}
Response.Write(s);
}
}
}
No comments:
Post a Comment