一:字符串类

  1   删除空格:

       1)   Trim() :         删除字符串前的空格;

       2) TrimStart :   删除前边的空格;

       3) TrimEnd:   删除后边的空格   

      例: string str=“    abcdefg”;

              int length=str.length;

              str= str.Trim();

              length=str.Length;

              console.write(str);

              console.read();

              

              

 2   转大小写:

      1)Toupper():     小写转大写

      2) Tolower():     大写转小写

     例:

          string str ="abcdefg";

          str=Touuper(str);

          consol.write(str);

          console.read();

 3  截取:Substring:

      例 : string str=“abcdefg”;

            str=str.substring(3);      

                                //     1) :把字符串 前几个截取出去;也就是还剩下(defg);

             str=str.substing (0,5);

                               //           2):从第一个字符下标 ,截取5个字符出来  ;也就是(abcde);                            

            console.writeline();

            console.read();

   4 索引值 : Index of  :

         例: string  str=“abcdefga”;

                 int  a=str.indexof('d');                                d在字符串str的位置从0开始数;也就是d的索引值为3 

                         =str.indexof("cd");                          从第一个字符开始数也就是c在字符串的位置;也就是cd的索引值为2

                 int  b=str.lastindexof("a");                       字符串中有相同的字符时,例如a,就从最后一个a数也就是a的索引值为7

                console.writeline(b);

                console.read();

   5 替换,移除:

               1)替换:Rplace:

               例: string str=“abcdefga”;

                      1) str=str.Replace("abc","XYZ");

                      2)str=str.Replace(“a”“X”);           注意:如果字符串里有相同字符并替换它时那么重复的字符的都替换      

               2) 移除:Rmove:

                例:

                      1) str= str.Remove(3);              从第三个位置字符开始后边的都移除

                      2) str=str.Remove(3,3);            从第三个位置移除后边的三个字符

 二:MATH类:

                   double a=3.33;

                1) 取上限 :

                   x=Math.Ceiling(a);

                2)四舍五入(整数):

                   x=Math.Round(a);       取小数点后一位:x=Math.Round(x*10)?10;        

                3)取下限:

                   x=Math.Floor(a);

                5)  取圆周率:

                   x=Math.PI

 三:时间类:

           1  时间定义:

               1)  DateTime  dt=new  DateTime(2017,01,12,12,00,00)

               2)  DateTime  dt= new DateTIME

                     dt=Convert.ToDateTime(2017-10-10 10:10:10)

               3) datetime now=datetime.now               :获取当前时间

            2   时间格式化  :

                console.writeline(dt.tostring("yyyy-mm-dd"));            设置时间表达方式    yyyy-年; MM-月; dd-日 ;hh 小时(12制),HH(24制):mm 分钟 ;ss 秒 ;ms毫秒

                console.read()        

           3   获取星期几

               console.writeline(now.dayofweek);

           4  获取今天是今年中的第几天

              date time dt= datetime.now;

              console.writeline(dt.dayofyear);

           5 获取指定时间到现在过了多少天:

               例:

               datetime dt=datetime.now;

               datetime dt1=new datetime(2017,08,10);

              timespan dt2=dt-dt1;

              console.writeline(dt2.days);

              console.read()                                   :就是从2017年08月10号到现在已经过了多少天