摘要: 功能说明:在此例中,try 块包含对可能导致异常的ProcessString()方法的调用.catch子句包含仅在屏幕上显示消息的异常处理程序,当从ProcessString内部调用throw语句时,系统查找Catch语句并显示Exception caught消息. class Try_Test1 { static void processString(string s) { if (s == null) { throw new ArgumentNullException(); } } static void Main() { try { string s = null; processStr 阅读全文
posted @ 2013-10-26 12:54 shaoyi52 阅读(258) 评论(0) 推荐(0) 编辑
摘要: //用迭代算法算出第m个值 //1,1,2,3,5,8...;//{1,0+1,1+1,1+2,2+3 ,3+5} static void Main(string[] args)//Main方法 必须为静态方法 可以void (无返回参数)或者int (整型返回类型) { int sum = 1; int persum= 0; int m = Convert.ToInt32(Console.ReadLine()); int [] bn=new int[m+1]; bn[0] = 0; for (int i = 1; i<= m; i++) { bn[i] = bn[i-1]; s... 阅读全文
posted @ 2013-10-26 02:06 shaoyi52 阅读(489) 评论(0) 推荐(0) 编辑
摘要: //用Parse方法将字符串转换为数值类型;long num=Int64.Parse(args[2])//用别名为Int64c#类型long;long num=long.Parse(args[2])//还可以使用Convert类的方法ToInt64完成同样的工作;long num =Convert.toInt(s);foreach 可以访问数组,集合类或任何实现IEnumerable接口的类或结构 阅读全文
posted @ 2013-10-26 02:05 shaoyi52 阅读(352) 评论(0) 推荐(0) 编辑