摘要: using System;/* 异常异常处理 * 传统的错误表达方式: 错误码,举列 * 错误码的缺点:不处理的则很难发现,每次处理则很麻烦,难以看出错误的原因,容易使得程序进入不确定的状态 * try catch Exception ex异常也是对像 * Exception类主要属性: Message, StackTrace * 发生异常后程序默认就退出了,后续代码不会被执行了,catch以后的代码则会继承执行 * 不要吃掉异常 * 扔出自己的异常 * */namespace _12异常{ class Program { static void Main(strin... 阅读全文
posted @ 2012-02-25 09:04 简单--生活 阅读(164) 评论(0) 推荐(0) 编辑
摘要: using System;using System.Collections.Generic;using System.Linq;using System.Text;/* 定义类的时候不指定父类,则父类是Object类,Object类是任何类的直接或者间接父类 * */namespace _10继承{ class Program { static void Main(string[] args) { China c = new China(); c.Age = 22; c.Name = "向... 阅读全文
posted @ 2012-02-25 00:36 简单--生活 阅读(145) 评论(0) 推荐(0) 编辑
摘要: using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace _9对像的引用2{ class Program { static void Main(string[] args) { int i = 10; int j = i; //拷贝 i++; Console.WriteLine(j); //int, datetime,bo... 阅读全文
posted @ 2012-02-25 00:21 简单--生活 阅读(176) 评论(0) 推荐(0) 编辑
摘要: using System;using System.Collections.Generic;using System.Linq;using System.Text;/* 构造函数 * 构造函数是用来创建对像的特殊函数,函数名和类名一样,没有返回值,连void都不用 * 构造函数可以有参数,new对像的时候传递函数参数即可 * 构造函数可以重载,也就是有我个参数不同的构造函数 * 如果不指定构造函数,则类有一个默认的无参构造函数 * 如果指定了构造函数,则不再有默认的无参构造函数,如果需要无参构造函数,则需要自己来写 */namespace _8构造函数{ class Program ... 阅读全文
posted @ 2012-02-25 00:12 简单--生活 阅读(195) 评论(0) 推荐(0) 编辑
简单--生活(CSDN)