asp.net高级教程(二)- 转换编程思维(5) catch(SQLException e) { throw(new Exception("数据库出错:" + e.Message)) ; } } } } 这个bbs类很简单,有四个私有变量,对应四个只读属性,方法只有一个带参数的构造函数,作用是从数据库中读取相应的数据,填充四个私有变量。类构造好了,让我们看看如何使用,在需要显示论坛这些属性的页面文件里(.aspx)里,构造四个Label,象这样: <table width=140 cellpadding=4 cellspacing=1 border=0> <tr> <td class=cn> <font color=white>注册用户数:</font> </td> <td> <asp:label id="lblUserCount" runat=Server class=cn></asp:label> </td> </tr> <tr> <td class=cn> <font color=white>贴子总数:</font> </td> <td> <asp:label id="lblTopicCount" runat=Server class=cn></asp:label>