随笔分类 - c#开发指导
摘要:(1) try { } catch (Exception) { throw; } finally { } (2) using (SqlConnection conn=new SqlConnection("数据库连接字符串")) { }(3) try { using (SqlConnection conn=new SqlConnection("连接字符串"))...
阅读全文
摘要:接口的基本特征:1接口类似抽象类:继承接口的任何非抽象类型必须实现接口的所有成员.2不能直接实例化接口3:接口可以包含事件,索引器,方法,属性4:接口不包括方法的实现5类和结构可从多个接口继承6接口自身也可从多个接口继承例子:interface MyInterface { string ID { set; get; } string Name { set; get; } void Sho...
阅读全文
摘要: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...
阅读全文
摘要: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
阅读全文
摘要: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) {
阅读全文
摘要: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剩余的元素的个数有
阅读全文
浙公网安备 33010602011771号