STUDENT CLASS:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication18.Model
{
class student
{
int id;
string name;
static string collegename;
public student(int id,string name)
{
this.id = id;
this.name = name;
}
static student()
{
collegename = "Govt Dehli College";
}
public void display()
{
Console.ForegroundColor = System.ConsoleColor.Green;
Console.WriteLine("************************************");
Console.ForegroundColor = System.ConsoleColor.Magenta;
Console.WriteLine("EnrolmentID: "+id);
Console.WriteLine("Name : "+name);
Console.WriteLine("College: "+collegename);
Console.ForegroundColor = System.ConsoleColor.Green;
Console.WriteLine("************************************");
}
}
}
MAIN CLASS:
using ConsoleApplication18.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication18
{
class Program
{
static void Main(string[] args)
{
student[] s = new student[]
{
new student(123,"salman"),
new student(124,"ali"),
new student(125,"sana"),
new student(126,"kashif"),
};
foreach (student item in s)
{
item.display();
}
}
}
}