类 ( string )

/*         string s = Console.ReadLine();

         //   int i = s.Length;             .Length是  获取字符串长度,并返回一个int值!

         //   s=s.Trim();                   去除字符串   前 后   的空格!

         //  s = s.TrimStart();          去除字符串    前面    的空格!

         //  s = s.TrimEnd();             去除字符串   后面    的空格!

         //  s = s.ToUpper();           把小写转换成        大写!

         //  s = s.ToLower();            把大写转化成        小写! 

         //   s.Substring(6,8);            字符串 第一个字符是从0开始的。从一串数值的第7位开始截取8位数!                                                  //例如,输入370311/19920316/2379,此时被截取数值是  19920316.

           

          //  s=s.Replace("A", "a");      把输入的    A    全转变为   a    !

 

         //  int d=s.IndexOf("a");   输出的d表示字符串中第一个a ,在 字符串中是第几个,返回的是int值!                 

          //  d = s.IndexOf("a", 5);       这时输出的d表示字符串中从第5个字符以后的第一个a ,在 字符串中是第几个!            //  d = s.LastIndexOf("a");      这里表示最后的a的位置!

 

            // bool b=s.StartsWith("a");    判断字符串开头是不是a,返回ture/false

           // bool a = s.EndsWith("f");     判断字符串是不是以f结束 

           // bool b = s.Contains("aa");    判断字符串中是不是包含指定字符aa,返回ture/false

 

            例如:double i = double.Parse(s);

            s = i.ToString("#.##");         //四舍五入并且取小数点后2 位。当是int值时,不加.00            

             s = i.ToString("#.00");        //四舍五入并且取小数点后2 位。当时int值时,加.00

            s = i.ToString("#,#");          //整数部分从个位开始,每三位一组隔开。

            s = i.ToString("#,#.00");

            s = i.ToString("#,#.##");

             Console.WriteLine(s);

             Console.ReadLine();     */

 

 

/*          例如,

            string s = Console.ReadLine();

            string a = s.Substring(6, 4);

            Console.Write(a + "年");

            string b=s.Substring(10,2);

            Console.WriteLine(b + "月");

            Console.ReadLine();           

*/

 

posted @ 2014-10-17 15:47  安定祥和  阅读(144)  评论(0编辑  收藏  举报