How can I create correct struct array without using jagged array? I have tried -
student[] newarray = new student[]{student_info,student2_info};
Console.WriteLine(newarray[0]);
But i get "project name.student" in console
public struct student
{
public string Name { get; set; }
public string Last_Name { get; set; }
public string Address { get; set; }
public string City { get; set; }
public string Country { get; set; }
}
class H
{
static void Main(string[] args)
{
student student_info = new student();
student_info.Name = "Mike";
student_info.Last_Name = "Johnson";
student_info.Address = "Baker str. 84/4a";
student_info.City = "New LM";
student_info.Country = "Paris";
student student2_info = new student();
student student3_info = new student();
student student4_info = new student();
student student5_info = new student();
string[] my_array1 = { student_info.Name, student_info.Last_Name, student_info.Address, student_info.City, student_info.Country };
string[] my_array2 = { student2_info.Name, student2_info.Last_Name, student2_info.Address, student2_info.City, student2_info.Country };
string[] my_array3 = { student3_info.Name, student3_info.Last_Name, student3_info.Address, student3_info.City, student3_info.Country };
string[] my_array4 = { student4_info.Name, student4_info.Last_Name, student4_info.Address, student4_info.City, student4_info.Country };
string[] my_array5 = { student5_info.Name, student5_info.Last_Name, student5_info.Address, student5_info.City, student5_info.Country };
string[][] list = new string[][] { my_array1, my_array2, my_array3, my_array4, my_array5 };
for (int x = 0; x < 5; x++)
{
for (int y = 0; y <= 4; y++)
{
// Console.WriteLine(list[x][y]);
}
student[] newarray = new student[]{student_info,student2_info};
Console.WriteLine(newarray[0]);
}
}
}