Answer:
Check the explanation
Step-by-step explanation:
using System;
using System.Collections.Generic;
namespace Demo
{
//Written in C# programming language
struct BirthRecord
{
public string lastName;
public string firstName;
public float length;
public int pounds;
public int ounces;
};
class Program
{
static void Main()
{
List<BirthRecord> birthRecords = new List<BirthRecord>(); // List of the birthRecord
BirthRecord birthRecord1 = new BirthRecord(); //Creating Object to first birth record
birthRecord1.firstName = "Ravi";
birthRecord1.lastName = "Sankar";
birthRecord1.length = 10;
birthRecord1.pounds = 10;
birthRecord1.ounces = 10;
birthRecords.Add(birthRecord1); //Adding first record to list object
BirthRecord birthRecord2 = new BirthRecord(); // Creating Object to first birth record
birthRecord2.firstName = "Vinod";
birthRecord2.lastName = "Kumar";
birthRecord2.length = 20;
birthRecord2.pounds = 20;
birthRecord2.ounces = 20;
birthRecords.Add(birthRecord2); //Adding second record to list object
for (int i = 0; i < 1; i++) //For getting only one record for that i < 1 it will execute only one time
{
Console.WriteLine("Last name of the first baby born : " + birthRecords[0].lastName);
}
Console.ReadKey(); // For waiting result in console.
}
}
}
Kindly check the attached image below for the code output.