C# exercises and solutions-append record to list

C# structure: student records application

Append record to list

Step3: defining the add(student[] st, ref int itemcount) method to add a new record to the the array of student objects. This method takes two arguments. The first argument is the array of student objects(st) and the second argument is the number of items in the array. The two arguments are passed by references. For an array, we don't need to use the ref keyword when we want to pass it by reference. However, we need to use the ref keyword when we want to pass an argument of primitive type such as int, float, dobule,etc. When the new item is added the value itemcount variable increases by 1 that means the number of records in the list increases.

//method add/append a new record
static void add(student[] st,ref int itemcount){

Console.Write("Enter student's ID:");
st[itemcount].stnumber=Console.ReadLine().ToString() ;

//making sure the record to be added doesn't already exist

Console.WriteLine("This ID already exists.");
goto Again;


Console.Write("Enter student's Name:");

st[itemcount].stname=Console.ReadLine ().ToString();

Console.Write("Enter student's Sex(F or M):");

Console.Write("Enter student's quizz1 score:");

Console.Write("Enter student's quizz2 score:");

Console.Write("Enter student's assigment score:");

Console.Write("Enter student's mid term score:");

Console.Write("Enter student's final score:");


++itemcount; //increase the number of items by one



Joseph comment


I want to solve this program by any one
I/p:-1 1 2 4
O/p:-a a b d
k b d
a l d

Zet comment


goto?? wow


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.