编辑: 645135144 2015-08-25

public int Age { get { return

2015 - year;

} set { year =

2015 - value;

} } // setter public void setYear(int year) { if (year <

2015) this.year = year;

} } class Program { static void Main(string[] args) { Person john = new Person();

john.setYear(1988);

Console.WriteLine(john.Age);

john.Age = 35;

Console.WriteLine(john.Age);

物件导向 TQC+ C# 认证教学手册

11 物件导向 Console.ReadKey();

} } abstract class Animal { private string name;

public Animal(string name) { this.name = name;

} public void eat() { Console.WriteLine( {0} is eating. , name);

} } interface IPet { void play();

void eat();

} class Dog : Animal, IPet { public Dog(string name) : base(name) { } void IPet.play() { Console.WriteLine( 汪 );

} } class Cat : Animal, IPet { public Cat(string name) : base(name) { } void IPet.play() { Console.WriteLine( 喵 );

} } class Program { static void Main(string[] args) { Animal a = new Animal( 动物 TQC+ C# 认证教学手册

12 物件导向 List list1 = new List();

Dog dog1 = new Dog( doggy );

list1.Add(dog1);

Cat cat1 = new Cat( kitty );

list1.Add(cat1);

foreach (IPet pet in list1) pet.eat();

pet.play();

Console.ReadKey();

} } TQC+ C# 认证教学手册

13 物件导向 Terms File System Networking LINQ String Methods stock.txt 2317,鸿海 2330,台积电 3008,大立光 Program.cs using System;

using System.Collections.Generic;

using System.IO;

using System.Linq;

using System.Net;

using System.Text;

using System.Threading.Tasks;

class Stock { public string Id { get;

set;

} public string Name { get;

set;

} public double Price { get;

set;

} } class Program { private static List stocks = new........

下载(注:源文件不在本站服务器,都将跳转到源网站下载)
备用下载
发帖评论
相关话题
发布一个新话题