1、循环语句

(1)For

(2)While

(3)Dowhile

(4)For  each

 

(1)for(初始条件;比较;状态改变)

     {

循环体;

 }

2int i=0//初始条件

 Whilei<=9

 {

循环体;

I++//状态改变

 }

 (3int i=0

      Do

      {

 I++;

 循环体;

      }whilei<0);

     注意:do while…先执行,在判断。

2、跳转语句

Break 中断当前最近的整个循环;

Continue 中断本次循环后面的部分,直接跳往状态改变,继续下面的循环。

3、异常语句

Try

{

  代码;

}

Catchexecption e//将捕获的异常存到exception 类的变量e

{

  Console.writeline(e.Message);

}

Finally

{

  Console.writeline(“ ”);

}

注意:不管上面是否有错,finally都会执行。

 

 String

(1).length//获取当前字符串的长度,返回int

(2).trim()//去掉字符串中前后的空格

(3).trimstart()//去掉字符串中前面的空格

(4).trimend()//去掉字符串中后面的空格

(5).Toupper()//转为大写

(6).Tolower()//转为小写

(7).indexOf()//返回字符串中符合条件的字符串第一次出现的位置(索引从0开始)

(8).lastindexOf()//返回字符串中符合条件的字符串最后一次出现的位置(索引从0开始)

(9).startswith()//判断开头,返回bool型值

(10).endswith()//判断结尾,返回bool型值

(11).contains()//判断字符串中是否包含某个字符段,返回bool型值

(12).substring( , )//从指定索引位置截取指定长度的字符段,如果只写一个数,表示从这个位置截到最后

(13).tostring(“#.00”)//

 

Math

(1)math.celling()//上限取整

(2)Math.floor()//下限取整

(3)Math.pi()//π值

(4)Math.round()//四舍五入

(5)Math.sqrt()//开方

(6)Math.abs()//取绝对值

 

Datetime

(1)datetime d=new datetime();//创建时间

(2)Datetime d=datetime.now;//提取当前时间

(3)Add//加一定的时间

  Addyears()  Addmonths()  Adddays()  Addhours()  Addticks()

  Addminutes()  Addseconds()  Addmilliseconds()

(4).Dayofyear//返回是一年的第几天

(5).dayofweek//返回是星期几

  .tostring(“yyyy”)

  .tostring(“MM”)

  .tostring(“dd”)

  .tostring(“hh”)

  .tostring(“mm”)

  .tostring(“ss”)

 

Console.clear();//清空

Thread.sleep();//延时(要引用using system.threading

 posted on 2014-12-14 20:53  黑桃X  阅读(208)  评论(0编辑  收藏  举报