C#实用教程郑阿奇课后习题答案 联系客服

发布时间 : 星期一 文章C#实用教程郑阿奇课后习题答案更新完毕开始阅读2b00c42d580216fc700afd9c

Console .Read(); } }

5,下面的程序,输入不同的参数,分析运行结果。如分别别输入:test 5,test,test hello,test 0,test1212121212121212. using System; class Test {

public static void Main(string[] args) {

try {

int i=10/Int32.Parse(args[0]); }

catch (IndexOutOfRangeException e) {

Console,WriteLine(e,Message); }

catch(FormatException e) {

Console,WriteLine(e,Message); }

catch(DivideByZeroException e) {

Console,WriteLine(e,Message); }

catch(OverflowException e) {

Console,WriteLine(e,Message); } } }

6.指出下面代码错误的地方,并进行修改。 using System;

namespace Pave1Tsekov {

interfaceI1 {

void MyFuntion1(); }

interface I2 {

void MyFuntion2();

}

class Test:I1,I2 {

public void I1.MyFuntion1() {

Console.WriteLine (\); }

public void I2.MyFuntion2(0 {

Console.WriteLine (\); } }

class AppClass {

public static void Main(string[] args) {

Test t=new Test(0; t.MyFuntion1(); t.MyFuntion2(); } } }

7.分析下面的代码,指出Digit和Byte之间的转换方式,并说明原因。 using System;

public struct Digit {

byte value;

public struct(byte value) {

if (Value<0||value>9)

throw new ArgumentException(); this .value=value; }

public static implicit operator byte(Digit d) {

return d.value; }

public static implicit operator byte(byte b) {

return new Digit(b); } }

第五章 windows应用程序习题(选择和填空)

1、 项目在visual C#开发应用程序中的作用是什么?解决方案资源管理器的作用是什么? 2、 如何改变启动窗体?启动时是否不需要启动窗体? 3、 常用控件的公共属性有哪些?有哪些是容器? 4、 Button控件的主要作用是什么?

5、 TextBox控件的主要作用是什么?多行TextBox控件的主要作用是什么?

6、 RadioButton控件的主要作用是什么?为什么一般Radiobutton控件要和GroupBox控件

或Panel控件组合使用?

7、 CheckBox控件的主要作用是什么?为什么一般CheckBox控件要和GroupBox控件或

Panel控件组合使用?

8、 ListBox控件的主要作用是什么?怎样进行项目多选?

9、ComodoBox控件的主要作用是什么?ComodoBox和ListBox应用的场合有什么不同? 10、GroupBox控件的主要作用是什么?为什么说它是一个容器? 11、为什么要以编程的方式改变控件的属性? 12、菜单的作用是什么?怎样实现动态菜单?

13、怎样实现工具栏的功能?如何将工具栏的功能与菜单项一致起来?

14、StatusBar控件的主要作用是什么?怎样实现状态栏的功能?状态栏的内容如何设置? 状态栏的内容如何改变?

15、对话框和窗体有什么不同?什么时候使用对话框? 16、三种样式应用场合有什么不同?

17、为什么要定义访问键?定义访问键有哪些方法?

第八章 数据库应用习题

一.填空题

1.创建数据库连接使用的对象是____

2.在数据库应用中进行事务处理,需要用到连接对象的_______ 方法。 3.DataReader对象是通过Command对象的_______ 方法生成的。 4.DataSet可以看作一个_______ 中的数据库。

5.从数据源向DataSet中填充数据用DataAdapter对象的______ 方法,从DataSet向数据源更新数据用DataAdapter对象的 ______方法。需要显式的通过调用来实现数据的获取与更新,这是由ADO。NET的___—— 特性决定的。

6.已知表t_student(xh,name,class,sex),结果如下表: 字段名 Xh Name Class Sex 数据类型 Int Varchar Varchar Char 长度 6 10 15 2 是否为主键 是

用Command对象给表t_student插入一条记录(0001,“张三”,“信息32”,‘男’),请把程序补充完整。

using System.Data.SqlClient;

string myConnectionString;

myConnectionString=”Initial Catalog=Northwind;Data Source=localhost;Integrate Security=SSPI;”

_(1)__myConnection=new_(2)__( (3) )__; //定义连接对象

String myInsertQuery=”----(4)------”; //定义插入数据的字符串 -------(50------myCommand=new---(6)----( =(7)-- );//定义查询命令对象

myCommand.Connection=myConnection; -----(8)-----;

myCommand.---(8)----; //myConnection.Close(); //

打开连接 执行操作