求助:关于数组,指针的问题
上代码:程序代码:
//People类 public class People { public int Num; public int Age; public string Sex; public void MyPed() { Console.WriteLine("ped"); } } //Student类,继承People类 public class Student:People { public int StudentNum; public int Grade; public void MyStudent() { Console.WriteLine("student"); } } class Program { static void Main(string[] args) { //建立一个People类型的数组 People[] pedlist = new People[5]; for (int i = 0; i < 5; i++) { Student stu = new Student(); //创建Student类的对象 stu.Grade = i; //赋值 pedlist[i] = stu; //将对象存入pedlist中 } for (int i = 0; i < pedlist.Length; i++) { ////////////////////////////////////////// //通过遍历pedlist,输出每个stu的Grade值,调用MyStudent()函数 // //////////////////////////////////////// //这里不会了,用“pedlist[i].__”的方式不行呀 } Console.ReadLine(); } }求指导,拜谢!!