2 回答
TA贡献1876条经验 获得超5个赞
namespace shiyan3_2
{
public partial class Form4 : Form
{
//如果你想在Form4以外的地方调用那就声明为public 变量或public的属性。
Book[] book = new Book[10];
public Form4()
{
InitializeComponent();
}
private void Form4_Load(object sender, EventArgs e)
{
book[0] = new Book("chinese", "me", 21, 2,30 );
book[1] = new Book("english", "you", 28, 3, 40);
}
TA贡献1830条经验 获得超9个赞
namespace shiyan3_2
{
public partial class Form4 : Form
{
Book[] book;
public Form4()
{
InitializeComponent();
}
private void Form4_Load(object sender, EventArgs e)
{
book = new Book[10];
book[0] = new Book("chinese", "me", 21, 2,30 );
book[1] = new Book("english", "you", 28, 3, 40);
}
private void button2_Click(object sender, EventArgs e)
{
Form4 f = new Form4();
var val = book[0];
}
public class Book
{
string title;
string author;
int price;
int store;
int sellprice;
public Book()
{
}
public Book(string ti,string au,int pr,int st,int se)
{
title = ti;
author = au;
price = pr;
store = st;
sellprice = se;
}
}
}
- 2 回答
- 0 关注
- 144 浏览
添加回答
举报