110,557
社区成员
发帖
与我相关
我的任务
分享
public partial class 基础_obj_this : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
book b1=new book("ASP.NET",24.4f);
book b2 = new book("XML", 22f);
book[] arr = new book[] { b1,b2 };
//sinfo s = new sinfo("张三", "男", 20, arr);
sinfo s2 = new sinfo("张三", "男", 20, arr);
Response.Write(s2.info());
}
}
class sinfo
{
private string name;
private string sex;
private uint age;
private book[] b;
public sinfo(string n, string s, uint a, book[] b)
{
this.age = a;
this.sex = s;
this.name = n;
this.b=b;
}
public string info()
{
string all = "";
foreach (book t in b)
{
all += t.bookinfo;
}
return "姓名:" + this.name + "<br>性别:" + this.sex + "<br>年龄:" + this.age + "<br>书籍信息:" + all;
}
}
class book
{
private string bookn;
private float price;
public book(string bn,float p)
{
this.bookn = bn;
this.price = p;
}
public string bookinfo()
{
return this.bookn+","+this.price;
}
}