第四版 c#程序设计教程(课后习题答案代码)

{ return string.Format(\, no, name); } } public Form2()

{ InitializeComponent();}

private void button1_Click(object sender, EventArgs e) { Myclass[] st = new Myclass[3]; int i;

string mystr=\; try

{ //for (i = 0; i < 3; i++) 加上本for循环就不会出错 // st[i] = new Myclass(); st[0].input(1, \王华\); st[1].input(3, \曾丽\); st[2].input(2, \陈山\); for (i = 0; i < 3; i++)

mystr = mystr + st[i].getstud() + \; textBox1.Text = mystr; }

catch (Exception ex)

{ string str = ex.Message + \ + ex.Source + \ + ex.HelpLink ; MessageBox.Show(str);

} } } 课本288上机实验12

public partial class Form3 : Form { public Form3()

{ InitializeComponent(); }

private void button1_Click(object sender, EventArgs e) { string path = textBox1.Text; try

{ string[] dirs = Directory.GetDirectories(path); label2.Text = \子文件夹个数为:\ + dirs.Length; }

catch(Exception ex)

{ label2.Text = \不存在指定的文件夹!\; } }

private void Form3_Load(object sender, EventArgs e)

{ label2.Text = \;}}

第十三章课后题和本章例题相似,代码太长这里不写了。

联系客服:779662525#qq.com(#替换为@) 苏ICP备20003344号-4