using System;
class building{
public int a;
public int b;
public int c;
public void e()
{
Console.WriteLine("" + b / c + " area per person");
}
}
//声明个building对象class builaingDemo {
public static void Main()
{
building house = new building(); //定义名为 house 的 building 对象变量
building office = new building(); //定义office 的 building 对象变量
int d; house.c = 4; //定义building house c 等于4
house.b = 2500; //定义building house b 等于2500
house.a = 2; //定义building house a 等于2 office.c = 25; //定义building office c 等于25
office.b = 4200; //定义building office b 等于2005
office.a = 3; //定义building office a 等于3 d = house.b / house.c; // d 等于2500除4 等于 625 Console.WriteLine("house has:\n " +
house.a + " floors\n " +
house.c + " occupants\n " +
house.b + " total area");
house.e();
Console.WriteLine(); d = office.b / office.c; Console.WriteLine("house has:\n " +
office.a + " floors\n " +
office.c + " occupants\n " +
office.b + " total area");
office.e();
}
}哈哈 一样
class building{
public int a;
public int b;
public int c;
public void e()
{
Console.WriteLine("" + b / c + " area per person");
}
}
//声明个building对象class builaingDemo {
public static void Main()
{
building house = new building(); //定义名为 house 的 building 对象变量
building office = new building(); //定义office 的 building 对象变量
int d; house.c = 4; //定义building house c 等于4
house.b = 2500; //定义building house b 等于2500
house.a = 2; //定义building house a 等于2 office.c = 25; //定义building office c 等于25
office.b = 4200; //定义building office b 等于2005
office.a = 3; //定义building office a 等于3 d = house.b / house.c; // d 等于2500除4 等于 625 Console.WriteLine("house has:\n " +
house.a + " floors\n " +
house.c + " occupants\n " +
house.b + " total area");
house.e();
Console.WriteLine(); d = office.b / office.c; Console.WriteLine("house has:\n " +
office.a + " floors\n " +
office.c + " occupants\n " +
office.b + " total area");
office.e();
}
}哈哈 一样
解决方案 »
- C# winform 程序将.chm文件设置为嵌入式资源文件,现在要获取该文件,代码怎么写?
- c#获取webbrowser中弹出的对话框内容?
- wpf中如何实现居中的排版?
- 让TextBox不响应Tab
- 请大家帮个忙。分数好说。
- 说句CSDN的坏话
- 无法找到脚本库“/aspnet_client/system_web/1_14322/Webulvalidation.js".
- c# 读取IntPtr 中的数据
- 怎样建立一个Access数据库并创建几个表然后保存到指定的路径下?然后程序又怎么连接这个数据库,读取数据呢?
- 如何在一个窗口之内关闭一个已经打开的另一个窗口???
- 回滾(調用函數之間)
- 用图片制作一个自定义画笔
class building{
public int a;
public int b;
public int c;
public int e()
{
return b / c;
}
}
//声明个building对象class builaingDemo {
public static void Main()
{
building house = new building(); //定义名为 house 的 building 对象变量
building office = new building(); //定义office 的 building 对象变量
int d;
house.c = 4; //定义building house c 等于4
house.b = 2500; //定义building house b 等于2500
house.a = 2; //定义building house a 等于2 office.c = 25; //定义building office c 等于25
office.b = 4200; //定义building office b 等于2005
office.a = 3; //定义building office a 等于3 d = house.e(); // d 等于2500除4 等于 625 Console.WriteLine("house has:\n " +
house.a + " floors\n " +
house.c + " occupants\n " +
house.b + " total area" +
d + " area per person");
Console.WriteLine(); d = office.e(); Console.WriteLine("house has:\n " +
office.a + " floors\n " +
office.c + " occupants\n " +
office.b + " total area" +
d + " area per person");
}
}
字段要私有,属性可以公开客户端的代码不需要对类进行解释
在类的内部解释
class building{
public int a;//.....
public int b;//.....
public int c;//.....
public int e()//........
{
return b / c;
}
}