Pages

Subscribe:

Ads 468x60px

Sunday, March 25, 2012

Foreach loop in asp.net using C#


In this web programming we will learn the use of foreach loop in C#. a foreach loop allows you to loop through the items in a set of data.
With a foreach loop, you don’t need to create an explicit counter variable. Instead, you create
a variable that represents the type of data for which you’re looking. Your code will then loop
until you’ve had a chance to process each piece of data in the set.
Code for .cs file
 string[] strarry = {"One","Two","Three","Four"};
        foreach (string element in strarry)
        {
            System.Diagnostics.Debug.Write(element + " ");
        }


No comments:

Post a Comment