C# exercises and solutions-show all records in list


C# structure: student records application

Show all records in list

Step4: Defining the viewall(student[] st, int itemcount) method to display the list of all records in the set. To display all records, we need a while loop to traverse through the array of student objects.

static void viewall(student[] st,int itemcount)
{

int i = 0;

Console.WriteLine("{0,-5}{1,-20}{2,-5}{3,-5}{4,-5}{5,-5}{6,-5}{7,-5}{8}(column index)", "0", "1", "2", "3", "4", "5", "6", "7", "8");
Console.WriteLine("{0,-5}{1,-20}{2,-5}{3,-5}{4,-5}{5,-5}{6,-5}{7,-5}{8,-5}", "ID", "NAME", "SEX", "Q1", "Q2", "As", "Mi", "Fi", "TOTAL");

Console.WriteLine("=====================================================");

while (i < itemcount)
{

if (st[i].stnumber !=null )
{

Console.Write("{0,-5}{1,-20}{2,-5}", st[i].stnumber, st[i].stname, st[i].sex);

Console.Write("{0,-5}{1,-5}{2,-5}",st[i].quizz1,st[i].quizz2,st[i].assigment);

Console.Write("{0,-5}{1,-5}{2,-5}",st[i].midterm,st[i].final,st[i].total);

Console.Write("\n");
}

i = i + 1;



}

}



Comments

Comments

Name:
Comment:
Enter the text:
CAPTCHA image



This website intents to provide free and high quality tutorials, examples, exercises and solutions, questions and answers of programming and scripting languages:
C, C++, C#, Java, VB.NET, Python, VBA,PHP & Mysql, SQL, JSP, ASP.NET,HTML, CSS, JQuery, JavaScript and other applications such as MS Excel, MS Access, and MS Word. However, we don't guarantee all things of the web are accurate. If you find any error, please report it then we will take actions to correct it as soon as possible.