I'm trying out structures and I can't figure out how to use them inside of functions. Later on I'll need to develop a piece of code that'll allow me to add students and reenter some details.
namespace struct_example
{
struct student
{
public int s_id;
public String s_name, c_name, s_dob;
}
class Program
{
static void Main(string[] args)
{
student[] arr = new student[4];
for (int i = 0; i < 4; i++)
{
fillplz(i);
}
for (int i = 0; i < 4; i++)
{
showplz(i);
}
Console.ReadKey();
}
static void fillplz(int id)
{
Console.WriteLine("Please enter StudentId, StudentName, CourseName, Date-Of-Birth");
arr[id].s_id = Int32.Parse(Console.ReadLine());
arr[id].s_name = Console.ReadLine();
arr[id].c_name = Console.ReadLine();
arr[id].s_dob = Console.ReadLine();
}
static void showplz(int id)
{
Console.WriteLine(arr[id].s_id);
Console.WriteLine(arr[id].s_name);
Console.WriteLine(arr[id].c_name);
Console.WriteLine(arr[id].s_dob);
}
}
}