zoukankan      html  css  js  c++  java
  • 20150304 类

    首先学习了类,分为string类和Math类!

    一、string

    string x = Console.ReadLine();

    int i=x.Length;//Length是截取字符长度,返回一个int值

    x=x.Trimm();//去掉字符前后的空格

    x=x.ToLower;//大写变小写

    x=x.ToUpper://小写变大写

    string p = x.Substring(几,后);//截取字符、

    x=x.Contains;//包含

    x=x.IndexOF();//截至 之前的

      确定输入的是否是个邮箱,是并截取用户名!

    //string x = Console.ReadLine();             //if (x.Contains("@"))             //{             //    Console.WriteLine("这是一个邮箱!用户名是"+x.Substring(0,x.IndexOf("@")));//IndexOf  截取之前的

                //}             //  else             //{             //    Console.WriteLine("这不是一个邮箱!");             //}             //Console.ReadLine();

     //string x = "370321199403043316";             //int i = x.Length;                         //string y = x.Trim();             //Console.WriteLine(x); Console.WriteLine(y);             //Console.WriteLine(x=x.ToUpper());//小写变大写             //Console.WriteLine(x=x.ToLower());//大写变小写             //Console.WriteLine(x=x.ToUpper());//小写变大写

                            //string p = x.Substring(6,8);//截取字符段             //Console.WriteLine(p);             //string n = p.Substring(4,4);             //string j = p.Substring(4,2);             //string d = p.Substring(6, 2);             //Console.Write(d);             //Console.ReadLine();//string类,处理字符!

    二、Math类

     //double x = Math.PI;//圆周率             //Console.WriteLine(Math.Ceiling(x));//为整数取数时,取向上最近的整数

                //Console.WriteLine(Math.Floor(x));//取整数,不管小数

                //Console.WriteLine(Math.Round(x,2));//四舍五入,整数为奇数,5加上;为偶数,5舍去             //Console.ReadLine();//取数....

    Date Time  获取时间

    DayOfYear 获取日期是当年的第几天

    TimeSpan是一个时间间隔类型

    AddDays();是加多少天

     AddHours();加小时

    AddMonths();加月数

    AddYears();加年数

    烧开水

    先询问:“是否要烧开水(Y/N)”

    是的话执行--0°--100°(30°---水温了,50°---水热了,80°---水快开了,100°---水已经开了,  结束。)

    //            for (int t = 0; t <= 100; t++) //            { //                if (t == 30) //                { //                    Console.WriteLine("水温了!"); //                } //                else if (t == 50) //                { //                    Console.WriteLine("水热了!"); //                } //                else if (t == 80) //                { //                    Console.WriteLine("水快开了!"); //                } //                else if (t == 100) //                { //                    Console.WriteLine("水开了");

    //                } //                else //                { //Console.WriteLine(t+"度"); //                }                

    //            } //            Console.ReadLine();

  • 相关阅读:
    转ihone程序内发邮件,发短信,打开链接等
    plist 文件的读写
    转object c语法速成
    转iphone项目之间的引用。
    object c求nsstring 长度和去掉前后空格的方法
    object c runtime中类类型和消息支持检查
    转NSDictionary类使用
    设置UITableview 浮动的 header
    NSString 类型plist转为NSDictionary
    ObjectiveC Unicode 转换成中文
  • 原文地址:https://www.cnblogs.com/m123/p/4315704.html
Copyright © 2011-2022 走看看