refer: public enum Person { Male, Female } public struct Student { public string Name; public int Age; public Person person; public float[] Scores; } public class Test { public Test(Student student) { this.Student = student; } public Student Student { get; set; } } class Program { static void Main(string[] args) { Student student = new Student(); student.Name = "guwei4037"; student.Age = 30; student.person = Person.Male; student.Scores = new float[] { 89, 98, 77, 80, 95 }; Test test = new Test(student); Console.WriteLine("male or female:" + test.Student.person + "\r\n" + "name:" + test.Student.Name + "\r\n" + "age:" + test.Student.Age); test.Student.Scores.ToList<float>().ForEach((i) => Console.WriteLine(i)); } }
public enum Person
{
Male,
Female
} public struct Student
{
public string Name;
public int Age;
public Person person;
public float[] Scores;
} public class Test
{
public Test(Student student)
{
this.Student = student;
} public Student Student { get; set; }
} class Program
{
static void Main(string[] args)
{
Student student = new Student();
student.Name = "guwei4037";
student.Age = 30;
student.person = Person.Male;
student.Scores = new float[] { 89, 98, 77, 80, 95 }; Test test = new Test(student);
Console.WriteLine("male or female:" + test.Student.person + "\r\n" + "name:" + test.Student.Name + "\r\n" + "age:" + test.Student.Age);
test.Student.Scores.ToList<float>().ForEach((i) => Console.WriteLine(i));
}
}