Thursday, 15 October 2015

Foreach Loop in C#

using System;
class Program
{
    static void Main()
    {
        Console.WriteLine("Enter the number of Student");
        int NumberOfStudent = int.Parse(Console.ReadLine());
        string[] student=new string[NumberOfStudent];
        for (int i = student.GetLowerBound(0); i <= student.GetUpperBound(0); i++)
        {
            Console.WriteLine("Enter the {0} Student Name", i + 1);
            student[i] = Console.ReadLine();
        }
       
        foreach (string s in student)
        {
            Console.WriteLine("Name of Student is {0}",s);
        }
    }
}

No comments:

Post a Comment