C产品在市场上有哪些独特优势?
- 内容介绍
- 文章标签
- 相关推荐
本文共计229个文字,预计阅读时间需要1分钟。
java// 1// 公共接口:动物
2public interface IAnimal {
3void Behavior();
4// 行为方法,描述各种动物的特性
5}
67// 类:狗
8public class Dog : IAnimal {
9public void Behavior() {
10Console.WriteLine(我叫 + name());
11}
12}
1 //公共接口: "动物" 2 public interface IAnimal 3 { 4 void Behavior(); //行为方法,描述各种动物的特性 5 } 6 7 //类: 狗 8 public class Dog : IAnimal 9 { 10 public void Behavior() 11 { 12 Console.WriteLine(name() + "我晚上睡觉,白天活动"); 13 } 14 string name() 15 { 16 return "狗"; 17 } 18 } 19 20 //类: 猫 21 public class Cat : IAnimal 22 { 23 string info = "猫"; 24 public void Behavior() 25 { 26 Console.WriteLine(info + "我白天睡觉,晚上活动"); 27 } 28 } 29 //简单的应用: 30 static void Main(string[] args) 31 { 32 IAnimal myDog = new Dog(); 33 myDog.Behavior(); //输出: "狗我晚上睡觉,白天活动" 34 IAnimal myCat = new Cat(); 35 myCat.Behavior(); //输出: "猫我白天睡觉,晚上活动" 36 37 }
本文共计229个文字,预计阅读时间需要1分钟。
java// 1// 公共接口:动物
2public interface IAnimal {
3void Behavior();
4// 行为方法,描述各种动物的特性
5}
67// 类:狗
8public class Dog : IAnimal {
9public void Behavior() {
10Console.WriteLine(我叫 + name());
11}
12}
1 //公共接口: "动物" 2 public interface IAnimal 3 { 4 void Behavior(); //行为方法,描述各种动物的特性 5 } 6 7 //类: 狗 8 public class Dog : IAnimal 9 { 10 public void Behavior() 11 { 12 Console.WriteLine(name() + "我晚上睡觉,白天活动"); 13 } 14 string name() 15 { 16 return "狗"; 17 } 18 } 19 20 //类: 猫 21 public class Cat : IAnimal 22 { 23 string info = "猫"; 24 public void Behavior() 25 { 26 Console.WriteLine(info + "我白天睡觉,晚上活动"); 27 } 28 } 29 //简单的应用: 30 static void Main(string[] args) 31 { 32 IAnimal myDog = new Dog(); 33 myDog.Behavior(); //输出: "狗我晚上睡觉,白天活动" 34 IAnimal myCat = new Cat(); 35 myCat.Behavior(); //输出: "猫我白天睡觉,晚上活动" 36 37 }

