摘要: (1) try { } catch (Exception) { throw; } finally { } (2) using (SqlConnection conn=new SqlConnection("数据库连接字符串")) { }(3) try { using (SqlConnection conn=new SqlConnection("连接字符串"))... 阅读全文
posted @ 2013-04-25 18:28 才高远志 阅读(160) 评论(0) 推荐(0) 编辑
摘要: int.TryParse(str1, out i1)判断是否是正确的数字(不判断带小数),带输出参数 阅读全文
posted @ 2013-04-24 02:35 才高远志 阅读(79) 评论(0) 推荐(0) 编辑
摘要: CREATE TABLE 部门表1(部门ID int identity(1,1) primary key,部门编号 varchar(16) Not Null ,部门名称 nvarchar(50) not null ,部门职责 nvarchar(max) not null ,电话号码 varchar(50) null,传真 varchar(50)null,电子邮件 varchar(50)null,负责人 varchar(20)null,备注 nvarchar(max)null,) 阅读全文
posted @ 2013-04-11 20:52 才高远志 阅读(98) 评论(0) 推荐(0) 编辑
摘要: 接口的基本特征:1接口类似抽象类:继承接口的任何非抽象类型必须实现接口的所有成员.2不能直接实例化接口3:接口可以包含事件,索引器,方法,属性4:接口不包括方法的实现5类和结构可从多个接口继承6接口自身也可从多个接口继承例子:interface MyInterface { string ID { set; get; } string Name { set; get; } void Sho... 阅读全文
posted @ 2013-03-30 20:40 才高远志 阅读(204) 评论(0) 推荐(0) 编辑
摘要: 在c#中,继承,虚方法,与重写方法结合在一起才能实现多态性虚方法是指允许其子类重新定义的方法的方法,在声明时,需要使用virtual修饰符, 不能是私有的public virtual int add(int a,int b){return a+b;}重写方法也称覆盖,是在派生类使用override修饰符重写基类带有virtual修饰符的虚方法class Base(){public virtual stringGetName(){return "父级名称";}}calss SunClass:Base{public override string GetName(){retur 阅读全文
posted @ 2013-03-30 19:41 才高远志 阅读(264) 评论(0) 推荐(0) 编辑
摘要: class Program { static void Main(string[] args) { Example emp = new Example(); string result = emp.sell(); Console.WriteLine("原样输出-----" + result); result = emp.sell(": "); Console.WriteLine("插入字符串--" + result); resul... 阅读全文
posted @ 2013-03-30 18:56 才高远志 阅读(134) 评论(0) 推荐(0) 编辑
摘要: public bool isnumeric(string str) { char[] ch=new char[str.Length]; ch=str.ToCharArray(); for (int i = 0; i < ch.Length;i++ ) { if (ch[i] < 48 || ch[i] > 57) { return false; } } return true;} 阅读全文
posted @ 2013-03-22 00:50 才高远志 阅读(156) 评论(0) 推荐(0) 编辑
摘要: class Program { static void Main(string[] args) { Program p = new Program(); p.ShowInfo("cjijhsakj", 100, null);//参数赋null值,就会得不到效果 } public void ShowInfo(params object[] parameters) { string strOutPut = string.Empty; for (int i = 0; i < parameters.Length; i++) { if (parameters[i] == nul 阅读全文
posted @ 2013-03-10 10:27 才高远志 阅读(166) 评论(0) 推荐(0) 编辑
摘要: Int32 i = 10; Object obj = new Object(); try { obj = i; Console.Write("装箱成功\n"); // Console.Write() } catch(Exception ex) { Console.Write("装箱失败"); Console.Write(ex.ToString()); return; } try { Int64 j = (Int64)obj;//这里会出现错误 Console.Write("拆箱成功"); } catch(Exception ex) { 阅读全文
posted @ 2013-03-09 21:00 才高远志 阅读(112) 评论(0) 推荐(0) 编辑
摘要: static void Main(string[] args) { List<string> tmplist = new List<string>(); tmplist.Add("A"); tmplist.Add("B"); tmplist.Add("C"); for (int i = 0; i < tmplist.Count; i++) { tmplist.RemoveAt(i); } if (tmplist.Count > 0) { Console.Write("\n剩余的元素的个数有 阅读全文
posted @ 2013-03-09 20:58 才高远志 阅读(136) 评论(0) 推荐(0) 编辑