海拉尔邮局2号
发表于 2014-5-7 23:14:29
多谢楼主分享
nbtange
发表于 2014-5-7 23:02:14
我来看看是什么东西
宁生
发表于 2014-5-7 22:16:06
一直很困扰
laysheng
发表于 2014-5-6 15:12:21
看看,先顶了
hnsdchy
发表于 2014-5-6 11:53:12
看看吧,先顶下
icelee0403
发表于 2014-5-6 10:28:22
来学习了{:1_1:}
zlhforever
发表于 2014-5-6 10:24:47
来学习了!!!!!!!!!
king38492378
发表于 2014-5-6 04:09:07
来学习了!!!!!!!!!
喜欢散步
发表于 2014-5-6 02:12:11
好东西 , 要看看
Stillthekid
发表于 2014-5-6 00:57:23
感谢楼主的分享啊
fpenetrate
发表于 2014-5-5 23:41:25
这好东西。。。要看看
fred009
发表于 2014-5-5 23:30:20
学习学习:victory:
Wade
发表于 2014-5-5 23:28:06
付出就会有回报
枯树火影
发表于 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
看了这张图你马上明白什么是变量
应该不错