c#类的例子
C#类的例子
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
//关于类的例子
namespace 类的例子
{
public class Program
{
public static void Main(string[] args)
{
动物 d = new 动物();
d.物种 = "植食动物";
d.size = "20";
Console.WriteLine(d.Eats("草","马"));
Console.ReadKey();
}
public class 动物 //定义”动物“类
{
public string size; //定义”动物“的大小;
public string 物种; //定义”动物“的物种
public string Eats(string food, string ali)
//动物的方法
{
string re ="重量"+ size + "KG的" + ali + "吃" + food + ",它是" + 物种;
return re;
}
}
}
}
文章来源:www.900544.com
浙公网安备 33010602011771号