枯树火影 发表于 2014-5-5 23:27:58

谢谢lz分享

黑色 发表于 2014-5-5 23:25:47

namespace ConsoleApplication
{
    class Program
    {
      static void Main(string[] args)
      {
            ArrayList myList = new ArrayList();
            myList.Add(new Student("王同学", 12, '男', "唱歌"));
            myList.Add(new Teacher("刘老师", 30, '女', 20));

            foreach (Person item in myList)
            {
                item.SayHello();
            }
            Console.ReadKey();
      }
    }

    public abstract class Person
    {
      public Person() { }

      public Person(string name, int age, char sex)
      {
            this.name = name;
            this.age = age;
            this.sex = sex;
      }

      private string name;
      private int age;
      private char sex;

      public string Name
      {
            get { return name; }
            set { name = value; }
      }

      public int Age
      {
            get { return age; }
            set { age = value; }
      }

      public char Sex
      {
            get { return sex; }
            set { sex = value; }
      }

      public abstract void SayHello();

      public virtual void Greet()
      {
            Console.Write("我叫:{0},我今年:{1}岁了,我是{2}生,", name, age, sex);
      }
    }

    public class Student : Person
    {
      public Student(string name, int age, char sex, string hobby)
            : base(name, age, sex)
      {
            this.hobby = hobby;
      }

      private string hobby;

      public string Hobby
      {
            get { return hobby; }
            set { hobby = value; }
      }

      public override void SayHello()
      {
            base.Greet();
            Console.WriteLine("我的爱好是:{0}", hobby);
      }

      public override void Greet()
      {
            base.Greet();
            Console.WriteLine("我的爱好是:{0}", hobby);

      }
    }

    public class Teacher : Person
    {
      public Teacher(string nane, int age, char sex, int year)
            : base(nane, age, sex)
      {
            this.year = year;
      }

      private int year;

      public int Year
      {
            get { return year; }
            set { year = value; }
      }

      public override void SayHello()
      {
            Console.WriteLine("我叫:{0},我今年:{1}岁了,我是:{2}生,我已经工作:{3}年了", Name, Age, Sex, year);
      }

      public override void Greet()
      {
            Console.WriteLine("我叫:{0},我今年:{1}岁了,我是:{2}生,我已经工作:{3}年了", Name, Age, Sex, year);
      }
    }

}

Dream。 发表于 2014-5-5 22:57:10

学习学习 ~~

━━≡Music≡━ 发表于 2014-5-5 22:40:54

赞一个,很想看噢!!!

红茶 发表于 2014-5-5 22:39:39

这东西找了好久勒,谢谢!!

聰明De阿甘 发表于 2014-5-5 22:36:41

看看,支持。。。

xqlsrjjjh 发表于 2014-5-5 22:29:39

看了这张图你马上明白什么是变量
应该不错

ε习以成惯 发表于 2014-5-5 22:16:30

真心感谢楼主的无私奉献!

Break.c 发表于 2014-5-5 19:14:09

看了这张图你马上明白什么是变量、指针和地址值

robinlai 发表于 2014-5-4 10:26:01

支持楼主 ,不容易啊

替天行道 发表于 2014-5-4 09:54:53

我也要学习一下下,顶起。。。。

TFWTY 发表于 2014-5-4 09:16:59

看图看图,哎,还要隐藏

tang59281 发表于 2014-5-4 08:48:04

我也来学习学习

苏小宁 发表于 2014-5-4 08:34:41

这么强大的图片的看看是什么样子的!!

584250550 发表于 2014-5-4 07:17:24

俺来瞧瞧,啦啦啦啦啦拉了拉

斯盖丸 发表于 2014-5-4 06:46:28

第一次来,所以要好好学学

a1396362522 发表于 2014-5-4 04:48:21

:sad学习学习

纸子 发表于 2014-5-4 01:59:37

看了这张图你马上明白什么是变量、指针和地址值

ccc88001 发表于 2014-5-4 01:10:04

来看看到底咋回事

幻化成风 发表于 2014-5-3 23:34:06

看看,学学
页: 212 213 214 215 216 217 218 219 220 221 [222] 223 224 225 226 227 228 229 230 231
查看完整版本: 看了这张图你马上明白什么是变量、指针和地址值(更正)