c# 2024新年学习大总结(史上最全)

using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection.Emit;
using System.Runtime.Serialization.Formatters.Binary;
using System.Security.Policy;
using System.Text;
using System.Threading.Tasks;

namespace c_学习
{
    internal class Program
    {
        /// <summary>
        /// 
        /// </summary>
        /// <param name="args"></param>
        static void Main(string[] args)
        {
            /*
            1、.Net平台.Net FrameWork框架
            .Net FrameWork框架提供了一个稳定的运行环境,;来保障我们.Net平台正常的运转

            2、C#语言 c sharp
            编程语言,如果你想要计算机按照你说的去做,你必须说计算机能够听懂的语言。


            2001年 any time any place and on any device
            任何时间任何地点都能够让用户通过任何设备获取到用户想要的数据

            1997 李开复 XXX

            乔布斯 windows phone ====》安卓 ===》wp7 ===》 wp8 ======> unity3D

            Unity3D 老鼠---猫
            c#
            JS
            BOO

            3、两种交互模式
            C / S:要求客户的电脑上必须要安装一个客户端:qq、360、快播等.....
            B / S:要求客户的电脑上只需要安装一个浏览器。

            4、IDE
            IDE指的就是我们的开发工具。

            5、vs的学习
            1)、启动VS
            a、双击图标
            b、调出cmd,输入 devenv

            2)、解决方案、项目及类之间的关系
            解决方案:公司
            项目:部门
            类:员工
            在视图里面找解决方案资源管理器

            3)、Program中的各个组成部分
            引用命名空间:
            京东----》京东在线商城项目-- -》顾客类
            淘宝----》淘宝在线商城项目-- -》顾客类

            高端霸气公司----》老赵牛X项目-- -》顾客类

            4)、方法或者函数
            Main函数是我们程序的主入口,你写的代码如果想要被执行的话,必须写在Main函数当中。

            5)、
            .sln:解决方案文件,里面包含着整个解决方案的信息,可以双击运行。
            .csproj: 项目文件,里面包含着这个项目的信息,可以双击运行。

            6、书写代码需要注意的地方:
            1、代码中出现的所有标点都是英文半角 shift键快速切换中文半角和英文半角
            shift + 空格 切换全角 / 半角
            2、在c#代码中,每行代码的结束,我们都以分号结束,注意:这个分号也是英文半角的分号。
            3、Console.WriteLine("要打印的内容");
                        Console.ReadKey();
                        1)、暂停当前程序,等待用户按下任意键继续,按下的任意键将显示在我们的控制台当中

            7、运行程序的两种方式
            1、点击绿色的启动按钮
            2、使用快捷键F5

            8、生成解决方案
            帮助我们排查语法错误。




            1、注释符
            1)、注销
            2)、解释

            2、c#的3种注释符
            1)、单行注释 //
            2)、多行注释 /*要注释的内容*/
            //          3)、文档注释 /// 多用来解释类或者方法


            /*
                        3、变量
                        用来在计算机当中存储数据。


                        孙全 开房
                        火车 26小时 去旅馆睡觉
                        孙全 一个人  单人房  308
                        孙全 and  girl 双人间  一张床 521
                        孙全 and  boy 双人间 两张床  520

                        存储整数100
                        数据类型:整数
                        在内存中开辟的空间应该是整数类型 int

                        存储变量的语法:
                        变量类型 变量名;
                                    变量名 = 值;

                                    "="号:在这并不表示等于的意思,而是赋值的意思,表示把等号右边的值赋值给等号左边的变量。

                        声明并且给变量赋值的简写形式:
                        变量类型 变量名 = 值;

                                    4、数据类型
                        1)、整数类型:int 只能存储整数,不能存储小数。
                        2)、小数类型:double 既能存储整数,也能存储小数,小数点后面的位数 15~16位。
                        3)、金钱类型:decimal:用来村粗金钱,值后面需要加上一个m.
                        4)、字符串类型: string, 用来存储多个文本,也可以存储空,字符串类型的值需要被 双引号引来,
                        这个双引号必须是英文半角状态下的双引号
                        5)、字符类型:char, 用来存储单个字符,最多、最少只能有一个字符,不能存储空。
                        字符类型的值需要用 单引号因起来。英文半角状态下的单引号。

                        5、波浪线
                        1)、如果你的代码中出现了红色的波浪线,意味着你的代码中出现了
                        语法错误。
                        2)、如果你的代码中出现了绿色的波浪线,说明你的代码语法并没有错误,
                        只不过提示你有可能会出现错误,但是不一定会出现错误。警告线

                        6、变量的使用规则
                        如果你要是用变量的话,应该要先声明再赋值再使用。


                        7、命名规则:
                        ****首先要保证的就是这个变量的名字要有意义。
                        1 现阶段给变量起名字的时候都以字母开头
                        2 后面可以跟任意“字母”、数字、下划线.
                        注意:
                        1)你起的变量名不要与c#系统中的关键字重复.
                        2)在c#中,大小写是敏感的.  HTML
                        3)同一个变量名不允许重复定义(先这么认为, 不严谨)

                        给变量起名字的时候要满足两个命名规范:
                        1、Camel 骆驼命名规范。要求变量名首单词的首字母要小写,其余每个单词的首字母要大写。
                        多用于给变量命名。
                        2、Pascal 命名规范:要求每个单词的首字母都要大写,其余字母小写。多用于给类或者方法命名。
                        HighSchoolStudent

                        highSchoolStudent


                        8、赋值运算符
                        =:表示赋值的意思,表示把等号右边的值,赋值给等号左边的变量。
                        由等号连接的表达式称之为赋值表达式。
                        注意: 每个表达式我们都可以求解除一个定值,对于赋值表达式而言,等号左边的变量的值,
                        就是整个赋值表达式的值。
                        int number = 10;

                                    9、+号的作用
                        1)、连接:当 + 号两边有一边是字符串的时候,+号就起到连接的作用。
                        2)、相加:两边是数字的时候


                        10、占位符
                        使用方法:先挖个坑,再填个坑。
                        使用占位符需要注意的地方:
                        1、你挖了几个坑,就应该填几个坑,如果你多填了,没效果。
                                                         如果你少填了,抛异常。
                        2、输出顺序:按照挖坑的顺序输出。


                        11、异常
                        异常是指:语法上并没有任何错误,只不过在程序运行的期间,由于某些原因出现了问题,
                        使程序不能再正常的运行。


                        12、转义符
                        转义符指的就是一个'\'+一个特殊的字符,组成了一个具有特殊意义的字符。
                        \n: 表示换行
                        \":表示一个英文半角的双引号
                        \t: 表示一个tab键的空格
                        \b: 表示一个退格键,放到字符串的两边没有效果。
                        \r\n: windows操作系统不认识\n,只认识\r\n
                        \\:表示一个\

                        @符号
                        1、取消\在字符串中的转义作用,使其单纯的表示为一个'\'
                        2、将字符串按照编辑的原格式输出

                        13、算数运算符
                        +
                        -
                        *
                        /
                        %

                        14、类型转换
                        隐式类型转换:
                        我们要求等号两遍参与运算的操作数的类型必须一致,如果不一致,满足下列条件会发生
                        自动类型转换,或者称之为隐式类型转换。
                        两种类型兼容
                        例如:int 和 double 兼容(都是数字类型)
                        目标类型大于源类型
                        例如:double > int   小的转大的


                        显示类型转换:
                        1、两种类型相兼容  int--double
                        2、大的转成小的  double----int
                        语法:
                        (待转换的类型)要转换的值;

                                    总结:
                        自动类型转换:int----> double
                        显示类型转换:double--->int


                        20平
                        20平 4  5平

            */



            //======  注释

            /// <summary>
            /// 
            /// </summary>
            /// <param name="args"></param>

            //

            /* .... */

            //====== #region

            #region 这些代码实现了XX功能
            Console.WriteLine("fdsfdsf");
            Console.WriteLine("fdsfdsf");
            #endregion



            //====== 变量

            //变量类型 变量名;
            // 变量名 = 值;
            //100

            ////官方语言:声明或者定义了一个int类型的变量
            //int number;//在内存中开辟了一块能够存储整数的空间
            ////官方语言:给这个变量进行赋值
            //number = 100;//表示把100存储到了这块空间内


            //int n = 3.14;


            //  double d = 3;

            //张三 李四 王五 赵六 abcdefg

            //string zsName = "张三";
            //string s="";//字符串可以存储 空

            ////字符串 字符  羊肉串和羊肉 
            //char gender = '男女';
            // char c='';


            //decimal money = 5000m;

            double d = 36.6;
            Console.WriteLine(d);
            Console.ReadKey();


            //====== 变量使用规则

            int number;//声明或者定义了整数类型的变量
            number = 20;
            // Console.WriteLine(number);
            Console.ReadKey();

            // String s = "颤三";
            string ss = "李四";

            //======  变量命名规范
            //
            //int number_1 = 10;
            //int number_2 = 20;

            //int number = 10;
            //int Number = 10;

            int number;
            //  int  number = 10;
            // int string=10;
            //int a = 10;
            //int b = 20;

            //======  变量赋值
            int n = 10;
            n = 50;//重新赋值,一旦给一个变量重新赋值,那么老值就不存在了,取而代之的新值。
            Console.WriteLine(n);
            Console.ReadKey();


            //====== +号的使用

            //string name = "王五";
            //Console.WriteLine("你好,"+name);

            Console.WriteLine(5 + "5");
            Console.ReadKey();

            //======  复习2个练习

            //有个叫卡卡西的人在旅店登记的时候前台让他填一张表,
            //这张表的里的内容要存到电脑上,
            //有姓名、年龄、邮箱、家庭住址,工资.
            //之后把这些信息显示出来
            //string name = "卡卡西";
            //int age = 30;
            //string email = "kakaxi@qq.com";
            //string address = "火影村";
            //decimal salary = 5000m;

            //Console.WriteLine("我叫{0},我今年{1}岁了,我住在{2},我的邮箱是{3},我的工资是{4}", name, age, address, email, salary);


            //Console.WriteLine("我叫" + name + ",我住在" + address + ",我今年" + age + "岁了" + ",我的邮箱是" + email + ",我的工资是" + salary);
            //Console.ReadKey();


            //int age = 18;
            //age = 81;
            //Console.WriteLine("原来你都" + age + "岁了呀");
            //Console.ReadKey();


            //3.定义四个变量,分别存储一个人的姓名、性别(Gender)、年龄、电话
            //(TelephoneNumber)。然后打印在屏幕上 (我叫X,我今年 X岁了,我是X生,
            //我的电话是XX)(电话号用什么类型,如:010-12345)
            string name = "张三";
            char gender = '男';
            int age = 18;
            string tel = "12345678900";
            Console.WriteLine("我叫{0},我今年{1}岁了,我是{2}生,我的电话是{3}", name, age, gender, tel);
            Console.ReadKey();

            /*
             变量:存储数据
             * 赋值运算符
             * 数据类型:
             * int 整数
             * double decimal string char 
             * 命名规范
             * Camel:
             * Pascal
             * 注释:
             * //
             * 
             ///
             * +号
             */

            //====== 占位符

            int n1 = 10;
            int n2 = 20;
            int n3 = 30;
            Console.WriteLine("第一个数字是{1},第二个数字是{0},第三个数字是{2}", n1, n2, n3);
            Console.WriteLine("第一个数字是:" + n1 + ",第二个数字是:" + n2 + ",第三个数字是:" + n3);
            Console.ReadKey();


            //====== 交换变量

            //int n1 = 10;
            //int n2 = 20;

            //int temp = n1;
            //n1 = n2;
            //n2 = temp;


            //Console.WriteLine("交换后,n1的值是{0},n2的值是{1}", n1, n2);
            //Console.ReadKey();

            //请交换两个int类型的变量,要求:不使用第三方的变量
            int n1 = 50;
            int n2 = 30;
            //n1=20  n2=10;

            n1 = n1 - n2;//n1=-10 n2=20
            n2 = n1 + n2;//n1=-10 n2=10
            n1 = n2 - n1;
            Console.WriteLine("交换后,n1的值是{0},n2的值是{1}", n1, n2);
            Console.ReadKey();

            //====== 接收用户的输入

            //Console.WriteLine("请输入你的姓名");
            ////我们还想要接收你输入的姓名
            ////接收用户在控制台的输入  11  3.14  男  张三
            //string name = Console.ReadLine();

            //Console.WriteLine("您的姓名是{0}", name);
            //Console.ReadKey();

            //1.练习:问用户喜欢吃什么水果(fruits),假如用户输入”苹果”,则显示”哈哈,这么巧,我也喜欢吃苹果”
            //Console.WriteLine("美女,你喜欢吃啥子水果哟~~~~");
            //string fruit = Console.ReadLine();
            //Console.WriteLine("这么巧呀,我也喜欢吃{0}", fruit);
            //Console.ReadKey();

            //2.练习:请用户输入姓名性别年龄,当用户按下某个键子后在屏幕上显示:您好:XX您的年龄是XX是个X生
            //Console.WriteLine("请输入您的姓名");
            //string name = Console.ReadLine();

            //Console.WriteLine("请输入您的年龄");
            //string age = Console.ReadLine();


            //Console.WriteLine("请输入您的性别");
            //string gender = Console.ReadLine();

            //Console.WriteLine("{0}你的年龄是{1}是个{2}生",name,age,gender);
            //Console.ReadKey();

            //====== 转移符

            //  Console.WriteLine("今天天气好晴\n朗处处好风光");


            //Console.WriteLine("我想在这句话中输出一\"\"个英文半角的双引号");

            //string name1 = "张三";
            //string name2 = "李思思";
            //string name3 = "王小五";
            //string name4 = "李狗蛋";
            //Console.WriteLine("{0}\t{1}", name1, name2);                                                            
            //Console.WriteLine("{0}\t{1}", name3, name4);


            //Console.WriteLine("学习编\b程有用\b么?学了不一定会,会了不一定能找到工作,找到工作 不应能买的起房子,买的起房子不一定娶得起老婆,娶得起老婆不一定生的了孩子,生的了孩子不一定是你的\b");

            //Console.ReadKey();



            //string str = "今天天气好晴\r\n朗处处好风光";

            //System.IO.File.WriteAllText(@"C:\Users\SpringRain\Desktop\1111.txt", str);
            //Console.WriteLine("写入成功!!!");
            //Console.ReadKey();


            //char c = '\b';//\ 在里面起到了一个转义的作用
            //char cc='bb';

            //string path=@"F:\老赵生活\music\a\b\c\d\e\小泽玛利亚.avi";
            //Console.WriteLine(path);
            //Console.ReadKey();


            Console.WriteLine(@"今天天气好晴
朗处处好风光");
            Console.ReadKey();

            //====== 算术运算符

            //int n1 = 10;
            //int n2 = 3;
            //int result = n1 / n2;
            ////Console.WriteLine(result);
            ////Console.ReadKey();

            ////演示:某学生三门课成绩为,语文:90  数学:80  英语:67,编程求总分和平均分.
            //int chinese = 90;
            //int math = 80;
            //int english = 67;
            //Console.WriteLine("总成绩是{0},平均成绩是{1}", chinese + math + english, (chinese + math + english) / 3);
            //Console.ReadKey();


            //练习2:计算半径为5的圆的面积和周长并打印出来.(pi为3.14)面积:pi*r*r; Perimeter(周长)

            //=号两遍的数据类型必须一样
            //int r = 5;
            //double area = 3.14 * r * r;
            //double perimeter = 2 * 3.14 * r;
            //Console.WriteLine("圆的面积是{0},周长是{1}", area, perimeter);
            //Console.ReadKey();


            //练习3:某商店T恤(T-shirt)的价格为35元/件,
            //裤子(trousers)的价格为120元/条.小明在该店买了3件T恤和2条裤子,
            //请计算并显示小明应该付多少钱?


            //int T_shirt = 35;
            //int trousers = 120;
            //int totalMoney = 3 * T_shirt + 2 * trousers;
            //Console.WriteLine(totalMoney);

            //double realMoney = totalMoney * 0.88;
            //Console.WriteLine(realMoney);

            //Console.ReadKey();
            ////打8.8折后呢?

            //int number = 10;
            //int---double
            //double d = number;//自动类型转换 隐式类型转换   int--double

            //double d = 303.6;
            ////语法:
            ////(待转换的类型)要转换的值;
            ////double----int//强制类型转换  显示类型转换
            //int n = (int)d;
            //Console.WriteLine(n);
            //Console.ReadKey();

            //====== 类型转换

            int n1 = 10;
            int n2 = 3;
            double d = n1 * 1.0 / n2;
            Console.WriteLine("{0:0.0000}", d);
            Console.ReadKey();


            ////int n1 = 5;
            //double n1 = 5;
            //int n2 = 2;
            //double d = n1 / n2;
            //Console.WriteLine(d);
            //Console.ReadKey();

            //====== 复习

            /*
              变量
              * 
              * 赋值运算符=  int num=10;
              * 占位符 
              * 变量的命名规范
              * Camel:
              * Pascal:
              * +号的使用:
              * 1、连接   
              * string s1="123";
              * int num=5;
              * s1+num       num+100
              * 2、相加
              * 三种注释
              * //
              * ///
              * 快捷键
              * 算数运算符
              * +=*除%
              * 转义符
              * //  /"  /r/n /b  /t 
              * @ 1、取消\在字符串中的转义作用  2、按原格式输出字符串
              * 类型转换
              * 1、强制类型转换 显示类型转换
              * 2、自动类型转换  隐式类型转换
              * 
              * 类型兼容 double int
              * 
              * 

              */

            //int num = 10;
            //double d = num;//自动 小的转大的

            //double dd = 3.13;
            //int n = (int)dd;

            //====== 两道作业

            //练习,编程实现计算几天(如46天)是几周零几 天.  6周零4天
            //int days = 46;
            //int weeks = days / 7;
            //int day = days % 7;
            //Console.WriteLine("{0}天是{1}周零{2}天",days,weeks,day);
            //Console.ReadKey();


            //编程实现107653秒是几天几小时几分钟几秒?


            // 60*60  3600 *24=86400   86400

            int seconds = 107653;
            int days = seconds / 86400;//求得天数
            int secs = seconds % 86400;//求得求完天数后剩余的秒数
            int hours = secs / 3600;//求得小时数
            secs = secs % 3600;//求得小时数后剩余的秒数
            int mins = secs / 60;//求得分钟数
            secs = secs % 60;

            Console.WriteLine("{0}秒是{1}天{2}小时{3}分钟{4}秒", seconds, days, hours, mins, secs);
            Console.ReadKey();

            //====== 类型转换

            //显示类型转换、自动类型转换
            //int--double   double  ----int

            //string s = "123abc";
            ////将字符串转换成int或者double类型
            //double d = Convert.ToDouble(s);
            //int n = Convert.ToInt32(s);
            //Console.WriteLine(n);
            //Console.WriteLine(d);
            //Console.ReadKey();


            //让用户输入姓名 语文 数学 英语 三门课的成绩,
            //然后给用户显示:XX,你的总成绩为XX分,平均成绩为XX分。
            Console.WriteLine("请输入你的姓名");
            string name = Console.ReadLine();
            Console.WriteLine("请输入你的语文成绩");
            string strChinese = Console.ReadLine();
            Console.WriteLine("请输入你的数学成绩");
            string strMath = Console.ReadLine();
            Console.WriteLine("请输入你的英语成绩");
            string strEnglish = Console.ReadLine();


            double chinese = Convert.ToDouble(strChinese);
            double math = Convert.ToDouble(strMath);
            double english = Convert.ToDouble(strEnglish);

            double sumScore = chinese + math + english;
            double avg = (int)sumScore * 1.0 / 3;
            Console.WriteLine("{0}你的总成绩是{1}平均成绩是{2:0.00}", name, sumScore, avg);
            Console.ReadKey();

            //55 77  88  557788
            //由于字符串去相加的话,最终会变成相连接,如果要拿字符串类型的变量参与计算
            //需要将字符串转换成int或者double类型
            //int chinese = Convert.ToInt32(strChinese);
            //int math = Convert.ToInt32(strMath);
            //int english = Convert.ToInt32(strEnglish);

            //Console.WriteLine("{0}你的总成绩是{1},平均成绩是{2}", name, chinese + math + english, (chinese + math + english) / 3);
            //Console.ReadKey();

            //====== Convert类型转换

            //提示用户输入一个数字 接收 并且向控制台打印用户输入的这个数字的2倍
            Console.WriteLine("请输入一个数字");
            // string strNumber = Console.ReadLine();
            //将用户输入的字符串转换成int或者double类型
            double number = Convert.ToDouble(Console.ReadLine());
            Console.WriteLine(number * 2);
            Console.ReadKey();


            //====== 加加减减

            //  int number = 10;
            // // number++;
            ////  ++number;//number=number+1;
            // // number--;
            //  --number;
            //  Console.WriteLine(number);
            //  Console.ReadKey();

            //   int number = 10;
            ////   int result = 10 + number++;
            //   //int result = 10 + number;
            //   //number++;



            //   //int result = 10 + ++number;
            //   number++;
            //   int result = 10 + number;
            //   Console.WriteLine(number);
            //   Console.WriteLine(result);
            //   Console.ReadKey();


            //  int number = 10;
            ////  int result = 10 + number--;
            //  //int result = 10 + number;
            //  //number--;

            // // int result = 10 + --number;
            //  number--;
            //  int result = 10 + number;
            //  Console.WriteLine(number);
            //  Console.WriteLine(result);
            //  Console.ReadKey();

            // int a = 5;
            // a++;
            // ++a;
            // --a;
            // a--;
            // int b = a++ + ++a * 2 + --a + a++;
            //// int b = a + a * 2 + a + a;
            // //      5+7*2+6+6   7
            // Console.WriteLine(a);
            // Console.WriteLine(b);
            // Console.ReadKey();

            //如果你有了一个喜欢的女生,你应该好好学习,努力上个好大学,毕业找个高新的工作。
            //在你喜欢的女生结婚的时候 多随点份子钱。

            //====== 关系运算符

            //            大象的重量(1500)>老鼠的重量(1)
            //关系表达式的结果是bool类型
            // bool b = 1500 > 1;
            //  bool b = 3 > 1000;
            // bool b = 39 < 18;
            bool b = 20 == 20;
            Console.WriteLine(b);
            Console.ReadKey();
            //兔子的寿命(3)>乌龟的寿命(1000)
            //39<18
            //我的年龄(20)==你的年龄(20)

            //====== 逻辑运算符

            //让用户输入老苏的语文和数学成绩,输出以下判断是否正确,正确输出True,错误输出False
            //1)老苏的语文和数学成绩都大于90分
            Console.WriteLine("小苏,输入你的语文成绩");
            //string strChinese = Console.ReadLine();
            int chinese = Convert.ToInt32(Console.ReadLine());
            Console.WriteLine("小苏,请输入你的数学成绩");
            int math = Convert.ToInt32(Console.ReadLine());


            //bool b = chinese > 90 && math > 90;
            bool b = chinese > 90 || math > 90;
            Console.WriteLine(b);
            Console.ReadKey();

            //2)语文和数学有一门是大于90分的

            //====== 判断闰年

            //Console.WriteLine("请输入要判断的年份");
            //int year = Convert.ToInt32(Console.ReadLine());
            ////年份能够被400整除.(2000)
            ////年份能够被4整除但不能被100整除.(2008)


            ////逻辑与的优先级要高于逻辑或
            //bool b = (year % 400 == 0) || (year % 4 == 0 && year % 100 != 0);

            //Console.WriteLine(b);
            //Console.ReadKey();



            //  bool b = 5 < 3 && 5 > 3;

            bool b = 5 > 3 || 4 < 3;

            //====== 运算符复习

            /*
             变量类型:int double string char decimal  bool
             * 运算符:
             * 赋值运算符:=
             * 复合赋值运算符:+= -= *= /= %=
             * 算数运算符:+ - * / % ++ --
               关系运算符: > < >= <= == !=
             * 逻辑运算符: && ||  !
             * 类型转换:
             * 1、自动类型转换 小的转大的  int--->double
             * 2、强制类型转换 大的转小的  double-->int
             * 3、Convert
             */

            //====== if结构

            //编程实现:如果跪键盘的时间大于60分钟,那么媳妇奖励我晚饭不用做了
            Console.WriteLine("请输入你跪键盘的时间");
            int mins = Convert.ToInt32(Console.ReadLine());

            //如果跪键盘的时间>60分钟 则不做晚饭

            bool b = mins > 60;
            //如果你想表示的含义是当b的值为true的时候去执行if中代码,
            //那么 语法上  ==true可以省略
            //但是,如果你想表示的是当b==false的时候去执行if中代码,
            //语法上 ==false不能省略
            if (mins > 60)
            {
                Console.WriteLine("好老公,不用跪键盘了,去吃屎吧");
            }
            Console.ReadKey();

            //====== if结构练习

          
                //让用户输入年龄,如果输入的年龄大于23(含)岁,则给用户显示你到了结婚的年龄了.

                //Console.WriteLine("请输入你的年龄");
                //int age = Convert.ToInt32(Console.ReadLine());
                //bool b = age >= 23;
                //if (b)
                //{
                //    Console.WriteLine("你可以结婚啦");
                //}
                //Console.ReadKey();

                //如果老苏的(chinese  music)
                //语文成绩大于90并且音乐成绩大于80
                //语文成绩等于100并且音乐成绩大于70,则奖励100元.
                //Console.WriteLine("请输入老苏的语文成绩");
                //int chinese = Convert.ToInt32(Console.ReadLine());
                //Console.WriteLine("请输入老苏的音乐成绩");
                //int music = Convert.ToInt32(Console.ReadLine());

                //bool b = (chinese > 90 && music > 80) || (chinese == 100 && music > 70);

                //if (b)
                //{
                //    Console.WriteLine("奖励100元");
                //}
                //Console.ReadKey();

                //让用户输入用户名和密码,如果用户名为admin,密码为888888,则提示登录成功.
                Console.WriteLine("请输入用户名");
                string name = Console.ReadLine();
                Console.WriteLine("请输入密码");
                string pwd = Console.ReadLine();

                if (name == "admin" && pwd == "mypass")
                {
                    Console.WriteLine("登陆成功");
                }
                Console.ReadKey();

            //====== if else 练习

            //如果小赵的考试成绩大于90(含)分,那么爸爸奖励他100元钱,
            //否则的话,爸爸就让小赵跪方便面.
            //Console.WriteLine("请输入小赵的考试成绩");
            //int score = Convert.ToInt32(Console.ReadLine());
            //if (score >= 90)
            //{
            //    Console.WriteLine("奖励你一百块");
            //}
            //else
            //{
            //    Console.WriteLine("去跪方便面");
            //}
            //Console.ReadKey();

            //对学员的结业考试成绩评测
            //         成绩>=90 :A
            //90>成绩>=80 :B 	
            //80>成绩>=70 :C
            //70>成绩>=60 :D
            //         成绩<60   :E


            Console.WriteLine("请输入学员的考试成绩");
            int score = Convert.ToInt32(Console.ReadLine());
            //最正确的做法

            if (score >= 90)
            {
                Console.WriteLine("A");
            }
            else if (score >= 80)
            {
                Console.WriteLine("B");
            }
            else if (score >= 70)
            {
                Console.WriteLine("C");
            }
            else if (score >= 60)
            {
                Console.WriteLine("D");
            }
            //else if (score < 60)
            //{
            //    Console.WriteLine("E");
            //}
            else
            {
                Console.WriteLine("E");
            }

            Console.ReadKey();




            #region if的做法
            //if (score >= 90 && score < 100)
            //{
            //    Console.WriteLine("A");
            //}
            //if (score >= 80 && score < 90)//ctrl+k+d
            //{
            //    Console.WriteLine("B");
            //}
            //if (score >= 70 && score < 80)
            //{
            //    Console.WriteLine("C");
            //}
            //if (score >= 60 && score < 70)//98  88
            //{
            //    Console.WriteLine("D");
            //}
            ////else
            ////{
            ////    Console.WriteLine("E");
            ////}
            //if (score < 60)
            //{
            //    Console.WriteLine("E");
            //}
            #endregion
            #region if else-if
            //if (score >= 90)
            //{
            //    Console.WriteLine("A");
            //}
            //else//<90 
            //{
            //    if (score >= 80)
            //    {
            //        Console.WriteLine("B");
            //    }
            //    else//<80
            //    {
            //        if (score >= 70)
            //        {
            //            Console.WriteLine("C");
            //        }
            //        else//<70
            //        {
            //            if (score >= 60)
            //            {
            //                Console.WriteLine("D");
            //            }
            //            else//<60
            //            {
            //                Console.WriteLine("E");
            //            }
            //        }
            //    }
            //} 
            #endregion
            Console.ReadKey();

            //====== 

            //比较3个数字的大小 不考虑相等

            //分别的提示用户输入三个数字 我们接受并且转换成int类型
            //Console.WriteLine("请输入第一个数字");
            //int numberOne = Convert.ToInt32(Console.ReadLine());
            //Console.WriteLine("请输入第二个数字");
            //int numberTwo = Convert.ToInt32(Console.ReadLine());
            //Console.WriteLine("请输入第三个数字");
            //int numberThree = Convert.ToInt32(Console.ReadLine());


            //三种情况 应该使用 if else-if来做
            //如果第一个数字大于第二个数字 并且第一个数字还大于第三个数字 
            //if (numberOne > numberTwo && numberOne > numberThree)
            //{
            //    Console.WriteLine(numberOne);
            //}
            ////如果第二个数字大于第一个数字并且第二个数字大于第三个数字
            //else if (numberTwo > numberOne && numberTwo > numberThree)
            //{
            //    Console.WriteLine(numberTwo);
            //}
            ////如果第三个数字大于第一个数字并且第三个数字大于第二个数字
            //else
            //{
            //    Console.WriteLine(numberThree);
            //}


            //我先让第一个数字跟第二个数字比较 如果大于第二个数字 再让第一个数字跟第三个数字比较
            //if (numberOne > numberTwo)
            //{
            //    //如果第一个数字大于了第二个数字 再让第一个数字跟第三个数字比较
            //    if (numberOne > numberThree)
            //    {
            //        Console.WriteLine(numberOne);
            //    }
            //    else//第三个数字要大于第一个数字
            //    {
            //        Console.WriteLine(numberThree);
            //    }
            //}
            //else//第二个数字大于了第一个数字
            //{ 
            //    //让第二个数字跟第三个数字进行比较 如果第二个数字大于第三个数字  第二个数字最大 否则第三个数字最大
            //    if (numberTwo > numberThree)
            //    {
            //        Console.WriteLine(numberTwo);
            //    }
            //    else//第三个数字最大
            //    {
            //        Console.WriteLine(numberThree);
            //    }
            //}



            //练习1:提示用户输入密码,如果密码是“88888”则提示正确,否则要求再输入一次,
            //如果密码是“88888”则提示正确,否则提示错误,程序结束。
            //(如果我的密码里有英文还要转换吗,密码:abc1)

            //Console.WriteLine("请输入密码");
            //string pwd = Console.ReadLine();
            //if (pwd == "888888")
            //{
            //    Console.WriteLine("登陆成功");
            //}
            //else//要求用户再输入一次
            //{
            //    Console.WriteLine("密码错误,请重新输入");
            //    pwd = Console.ReadLine();
            //    if (pwd == "888888")
            //    {
            //        Console.WriteLine("输了两遍,终于正确了");
            //    }
            //    else//输入第二次错误
            //    {
            //        Console.WriteLine("两边都不对,程序结束");
            //    }
            //}

            //Console.ReadKey();




            //练习2:提示用户输入用户名,然后再提示输入密码,如果用户名是“admin”并且密码是“88888”,
            //则提示正确,否则,如果用户名不是admin还提示用户用户名不存在,
            //如果用户名是admin则提示密码错误.
            //Console.WriteLine("请输入用户名");
            //string name = Console.ReadLine();
            //Console.WriteLine("请输入密码");
            //string pwd = Console.ReadLine();


            ////第一种情况:用户名和密码全部输入正确
            //if (name == "admin" && pwd == "888888")
            //{
            //    Console.WriteLine("登陆成功");
            //}
            ////第二种情况:密码错误
            //else if (name == "admin")
            //{
            //    Console.WriteLine("密码输入错误,程序退出");
            //}
            ////第三种情况:用户名错误
            //else if (pwd == "888888")
            //{
            //    Console.WriteLine("用户名错误,程序退出");
            //}
            ////第四种情况:用户名和密码全部错误
            //else
            //{
            //    Console.WriteLine("用户名和密码全部错误,程序退出");
            //}



            //练习3:提示用户输入年龄,如果大于等于18,则告知用户可以查看,如果小于10岁,
            //则告知不允许查看,如果大于等于10岁并且小于18,
            //则提示用户是否继续查看(yes、no),如果输入的是yes则提示用户请查看,
            //否则提示"退出,你放弃查看"。

            //第一种情况  >=18   
            //第二种情况  <10
            //第三种情况  >=10  && <18

            Console.WriteLine("请输入你的年龄");
            int age = Convert.ToInt32(Console.ReadLine());

            if (age >= 18)
            {
                Console.WriteLine("看吧,早晚你都要知道的");
            }
            else if (age < 10)
            {
                Console.WriteLine("滚蛋,回家吃奶去");
            }
            else
            {
                Console.WriteLine("确定要看么?yes/no");
                //input 要么是yes要么是no
                string input = Console.ReadLine();
                if (input == "yes")
                {
                    Console.WriteLine("看吧,早熟的孩子,后果自负哟");
                }
                else//no
                {
                    Console.WriteLine("乖孩子,回家吃奶去吧");
                }
            }

            Console.ReadKey();

            //====== if else 复习

            //int number = 10;
            ////number++;
            //int result = 10 + --number;
            //Console.WriteLine(result);
            //Console.WriteLine(number);
            //Console.ReadKey();

            //int number = 10;

            //number += 100;


            //   > < >= <= == !=
            //&& || !
            // bool  true false

            // if  if -else  if else-if

            //====== 异常捕获

            //语法上没有错误,在程序运行的过程当中,由于某些原因程序出现了错误,不能再正常的运行。
            bool b = true;
            int number = 0;//声明了一个变量
            Console.WriteLine("请输入一个数字");
            try
            {
                //abc
                number = Convert.ToInt32(Console.ReadLine());//赋值

            }
            // Console.WriteLine("fdsfdsfds");
            catch
            {
                Console.WriteLine("输入的内容不能够转换成数字");
                b = false;
            }
            //我们如果要执行下面这行代码,需要满足某些条件。
            //让代码满足某些条件去执行的话,使用bool类型
            if (b)
            {
                Console.WriteLine(number * 2);//使用
            }
            Console.ReadKey();

            //====== switch(){}

            //李四的年终工作评定,如果定为A级,则工资涨500元,如果定为B级,
            //则工资涨200元,如果定为C级,工资不变,如果定为D级工资降200元,
            //如果定为E级工资降500元.
            //设李四的原工资为5000,请用户输入李四的评级,然后显示李四来年的工资
            bool b = true;
            double salary = 5000;
            Console.WriteLine("请输入对李四的年终评定");//a b c d e  乱七八糟
            string level = Console.ReadLine();

            //switch(变量或者表达式的值)
            //{
            //    case 值1:要执行的代码;
            //    break;
            //    case 值2:要执行的代码;
            //    break;
            //    case 值3:要执行的代码;
            //    break;
            //    ..........
            //    default:要执行的代码;
            //    break;
            //}
            switch (level)
            {
                case "A":
                    salary += 500;
                    break;
                case "B":
                    salary += 200;
                    break;
                case "C": break;
                case "D":
                    salary -= 200;
                    break;
                case "E":
                    salary -= 500;
                    break;
                default:
                    Console.WriteLine("输入有误,程序退出");
                    b = false;
                    break;
            }
            if (b)
            {
                Console.WriteLine("李四明年的工资是{0}元", salary);
            }
            Console.ReadKey();


            //ctrl+k+s
            #region if else-if的做法
            //if (level == "A")
            //{
            //    salary += 500;//salary=salary+500;
            //}
            //else if (level == "B")
            //{
            //    salary += 200;
            //}
            //else if (level == "C")
            //{

            //}
            //else if (level == "D")
            //{
            //    salary -= 200;
            //}
            //else if (level == "E")
            //{
            //    salary -= 500;
            //}
            //else//输入的不是ABCDE其中之一
            //{
            //    Console.WriteLine("输入有误,程序退出");
            //    b = false;
            //}
            //if (b)
            //{
            //    Console.WriteLine("李四来年的工资是{0}", salary);
            //} 
            #endregion
            Console.ReadKey();


            //0 0.5 1 1.5 2


            //======  switch练习

            //让用户输入姓名,然后显示出这个人上辈子是什么职业。
            //Console.WriteLine("请输入一个姓名,我们将显示出来这个人上辈子的职业");
            //string name = Console.ReadLine();
            ////老杨、老苏、老马、老蒋、老牛、老虎、老赵
            //switch (name)
            //{
            //    case "老杨": Console.WriteLine("上辈子是抽大烟的");
            //        break;
            //    case "老苏": Console.WriteLine("上辈子是个老鸨子");
            //        break;
            //    case "老马": Console.WriteLine("上辈子是老苏手下的头牌");
            //        break;
            //    case "老蒋": Console.WriteLine("上辈子是拉皮条的");
            //        break;
            //    case "老牛": Console.WriteLine("上辈子是一坨翔");
            //        break;
            //    case "老虎": Console.WriteLine("上辈子是个大病猫");
            //        break;
            //    case "老赵": Console.WriteLine("上辈子是光芒万丈救苦救难的菩萨呀");
            //        break;
            //    default: Console.WriteLine("不认识,估计是一坨翔");
            //        break;
            //}
            //Console.ReadKey();




            // 成绩>=90 :A      
            //90>成绩>=80 :B 	
            //80>成绩>=70 :C
            //70>成绩>=60 :D
            //         成绩<60  :E

            Console.WriteLine("请输入一个考试成绩");
            int score = Convert.ToInt32(Console.ReadLine()); //0-100

            switch (score / 10)//你要把范围 变成一个定值
            {
                case 10: //case 10要执行的代码跟case 9是一样的
                case 9:
                    Console.WriteLine("A");
                    break;
                case 8:
                    Console.WriteLine("B");
                    break;
                case 7:
                    Console.WriteLine("C");
                    break;
                case 6:
                    Console.WriteLine("D");
                    break;
                default:
                    Console.WriteLine("E");
                    break;
            }
            Console.ReadKey();

            //====== 判断闰年类

            /*
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _05判断闰年
    {
        class Program
        {
            static void Main(string[] args)
            {
                //请用户输年份,再输入月份,输出该月的天数.(结合之前如何判断闰年来做)
                Console.WriteLine("请输入一个年份");
                try
                {
                    int year = Convert.ToInt32(Console.ReadLine());
                    Console.WriteLine("请输入一个月份");
                    try
                    {
                        int month = Convert.ToInt32(Console.ReadLine());//1-12
                        if (month >= 1 && month <= 12)
                        {
                            int day = 0;//声明一个变量用来存储天数
                            switch (month)
                            {
                                case 1:
                                case 3:
                                case 5:
                                case 7:
                                case 8:
                                case 10:
                                case 12:
                                    day = 31;
                                    break;
                                case 2:
                                    //由于2月 有平年和闰年的不同  所以首先要判断一下当年是不是闰年
                                    if ((year % 400 == 0) || (year % 4 == 0 && year % 100 != 0))
                                    {
                                        day = 29;
                                    }
                                    else
                                    {
                                        day = 28;
                                    }
                                    break;
                                //4 6  9 11
                                default:
                                    day = 30;
                                    break;
                            }

                            Console.WriteLine("{0}年{1}月有{2}天", year, month, day);
                        }//if判断的括号
                        else
                        {
                            Console.WriteLine("输入的月份不符合要求,程序退出");
                        }
                    }//try月份括号
                    catch//跟月份配对
                    {
                        Console.WriteLine("输入的月份有误,程序退出");
                    }
                }//try年份的括号
                catch//跟年份的try配对
                {
                    Console.WriteLine("输入的年份有误,程序退出");
                }
                Console.ReadKey();
            }
        }
    }
*/


            //====== 循环结构

            //向控制台打印100遍 下次考试我一定要细心
            //循环体:Console.WriteLine("下次考试我一定要细心");
            //循环条件:打印的次数小于100遍

            //需要定义一个循环变量用来记录循环的次数 没循环一次,循环变量都应该自身加1
            //int i = 0;
            //while (i < 100)
            //{
            //    Console.WriteLine("下次考试我一定要细心\t{0}",i);
            //    i++;//没循环一次,都要自身加1,否则就是死循环
            //}
            //Console.ReadKey();


            // Console.WriteLine("下次考试我一定要细心");

            //求1-100之间所有整数的和
            //求1-100之间所有偶数的和
            //循环体:累加的过程
            //循环条件:i<=100
            //int i = 1;
            //int sum = 0;//声明一个变量用来存储总和
            //while (i <= 100)
            //{
            //    if (i % 2 != 0)
            //    {
            //        sum += i;

            //    }
            //    i++;
            //}
            //Console.WriteLine(sum);
            //Console.ReadKey();

            //====== break关键字的用法

            //int i = 1;
            //int j=1;
            //while (i <= 10)
            //{
            //    while (j <= 10)
            //    {
            //        Console.WriteLine("我是里面的while循环");
            //        j++;
            //        break;
            //    }
            //    Console.WriteLine("我是外面的while循环");
            //    i++;
            //}
            //Console.ReadKey();


            //int i = 0;
            //while (i < 10)
            //{
            //    Console.WriteLine("Hello 酷狗");
            //    break;
            //}
            //Console.ReadKey();

            // 要求用户输入用户名和密码 用户名只要不是admin 密码不是888888
            //循环体:提示用户输入用户名 我们接收  密码 接收 判断是否登陆成功
            //循环条件:用户名或密码错误
            string userName = "";
            string userPwd = "";
            while (userName != "admin" || userPwd != "888888")
            {
                Console.WriteLine("请输入用户名");
                userName = Console.ReadLine();
                Console.WriteLine("请输入密码");
                userPwd = Console.ReadLine();
            }
            Console.WriteLine("登陆成功");
            Console.ReadKey();

            //====== while循环的3个练习

            //输入班级人数,然后依次输入学员成绩,计算班级学员的平均成绩和总成绩
            //10 
            //循环体:提示输入学员成绩,接收,并转换成整数类型,累加到总成绩当中
            //循环条件:循环的次数小于等于班级人数

            //Console.WriteLine("请输入班级人数");
            //int count = Convert.ToInt32(Console.ReadLine());
            //int sum = 0;//用来存放总成绩
            //int i=1;//声明一个循环变量用来记录循环的次数
            //while (i <= count)
            //{
            //    Console.WriteLine("请输入第{0}个学员的考试成绩",i);
            //    int score = Convert.ToInt32(Console.ReadLine());
            //    //表示把每一个学员的成绩累加到总成绩当中
            //    sum += score;
            //    i++;
            //}
            //Console.WriteLine("{0}个人的班级总成绩是{1}平均成绩是{2}",count,sum,sum/count);
            //Console.ReadKey();


            //老师问学生,这道题你会做了吗?如果学生答"会了(y)",
            //则可以放学.如果学生不会做(n),则老师再讲一遍,再问学生是否会做了......
            //直到学生会为止,才可以放学.
            //直到学生会或老师给他讲了10遍还不会,都要放学


            //放学的两个条件:
            //1、会了
            //2、讲完第十遍 不管你会不会 我都放学

            //循环体:老师不停的提问,学生不停的回答,老师还要不停得奖
            //循环条件:学生不会、讲的次数小于10遍
            //string answer = "";
            //int i = 0;
            //while (answer !="yes" && i < 10)
            //{
            //    Console.WriteLine("这是我第{0}遍给你讲,你会了么?yes/no",i+1);
            //    answer = Console.ReadLine();//yes no
            //    //如果学生回答的是 会了 此时应该跳出循环
            //    if (answer == "yes")
            //    {
            //        Console.WriteLine("会了那就放学!!!");
            //        break;
            //    }
            //    i++;
            //}


            //2006年培养学员80000人,每年增长25%,
            //请问按此增长速度,到哪一年培训学员人数将达到20万人?

            //循环体:人数每年增长25%
            //循环条件:人数>=20万

            //double people = 80000;
            //int year = 2006;
            //while (people < 200000)
            //{
            //    people *= 1.25;
            //    year++;
            //}

            //Console.WriteLine("到第{0}年的时候人数将达到20万人",year);

            //Console.ReadKey();



            //提示用户输入yes或者no
            //要求:只能输入yes或者no,只要不是yes或者no就要求用户一直重新输入

            //循环体:提示用户输入 我们接收并且判断
            //循环条件:输入的不能是yes或者no

            //string input = "";//yes
            //while (input != "yes"&& input != "no")
            //{
            //    Console.WriteLine("请输入yes或者no");
            //    input = Console.ReadLine();
            //}



            //提示用户输入用户名和密码 要求用户名等于admin密码等于888888
            //只要用户名错误或者密码错误就重新输入
            //但是,最多只能输入3次

            //循环体:提示用户输入用户名和密码  接收  判断
            //循环条件:用户名或者密码错误  最多错误3次

            //int i = 1;
            //string userName = "";
            //string userPwd = "";
            //while ((userName != "admin" || userPwd != "888888") && i <= 3)
            //{
            //    Console.WriteLine("请输入用户名");
            //    userName = Console.ReadLine();
            //    Console.WriteLine("请输入密码");
            //    userPwd = Console.ReadLine();
            //    i++;
            //}
            //Console.ReadKey();


            //写两个循环
            //第一个循环提示用户A输入用户名 要求A的用户名不能为空,只要为空,就要求A一直重新输入

            //循环体:提示A输入用户名 接收  判断
            //循环条件:用户名为空

            string userNameA = "";
            while (userNameA == "")
            {
                Console.WriteLine("请输入用户名,不能为空");
                userNameA = Console.ReadLine();
            }
            //  Console.ReadKey();



            //第二个循环提示用户B输入用户名,要求B的用户名不能跟A的用户名相同 并且不能为空
            //只要为空,并且跟A的用户名相同,就一直提示用户B重新输入用户名


            //循环体:提示输入B的用户名 接收判断
            //循环条件:用户名为空 或者跟A的相同

            Console.WriteLine("请输入用户名,不能跟A相同,并且不能为空");
            string userNameB = Console.ReadLine();
            while (userNameB == "" || userNameB == userNameA)
            {
                if (userNameB == "")
                {
                    Console.WriteLine("用户名不能为空,请重新输入");
                    userNameB = Console.ReadLine();
                }
                else
                {
                    Console.WriteLine("用户名B不能跟A的用户名相同,请重新输入");
                    userNameB = Console.ReadLine();
                }
            }

            Console.ReadKey();

            //====== do-while循环

            //明天小兰就要登台演出了,老师说再把明天的演出的歌曲唱一遍,
            //如果满意,小兰就可以回家了.否则就需要再练习一遍,直到老师满意为止.(y/n)

            //循环体:小兰唱了一遍 问老师 满意么?老师回答
            //循环条件:老师不满意
            //Console.WriteLine("老师我唱的你满意么?");
            //string answer = Console.ReadLine();
            //while (answer == "no")
            //{
            //    Console.WriteLine("老师,我再唱一遍,你满意么?");
            //    answer = Console.ReadLine();
            //}
            //遇见这种首先执行一遍循环体,拿着执行后的结果再去判断是否执行循环的循环。
            //我们推荐使用do-while循环。
            //string answer = "";
            //do
            //{
            //    Console.WriteLine("老师,我唱的你满意么?yes/no");
            //    answer=Console.ReadLine();
            //}while(answer=="no");
            //Console.WriteLine("OK,放学回家~~~");
            //Console.ReadKey();


            //要求用户输入用户名和密码,只要不是admin、888888就一直提示用户名或密码错误,请重新输入
            //string name = "";
            //string pwd = "";
            //do
            //{
            //    Console.WriteLine("请输入用户名");
            //    name = Console.ReadLine();
            //    Console.WriteLine("请输入密码");
            //    pwd = Console.ReadLine();
            //} while (name != "admin" || pwd != "888888");
            //Console.WriteLine("登陆成功");
            //Console.ReadKey();


            //练习3:不断要求用户输入学生姓名,输入q结束.

            string name = "";
            while (name != "q")
            {
                Console.WriteLine("请输入学员姓名,输入q结束");
                name = Console.ReadLine();
            }
            Console.ReadKey();

            //do
            //{
            //    Console.WriteLine("请输入学员姓名,输入q结束");
            //    name = Console.ReadLine();

            //}while(name!="q");
            //Console.ReadKey();

            //====== 复习

            //练习4:不断要求用户输入一个数字,然后打印这个数字的二倍,当用户输入q的时候程序退出。
            //循环体:提示用户输入一个数字 接收 转换  打印2倍
            //循环条件:输入的不能是q

            //string input = "";
            //while (input != "q")
            //{
            //    Console.WriteLine("请输入一个数字,我们将打印这个数字的2倍");
            //    //不能直接转换成int类型 因为用户有可能输入q
            //    input = Console.ReadLine();//数字 q 乱七八糟
            //    if (input != "q")
            //    {
            //        try
            //        {
            //            int number = Convert.ToInt32(input);
            //            Console.WriteLine("您输入的数字的2倍是{0}", number * 2);
            //        }
            //        catch
            //        {
            //            Console.WriteLine("输入的字符串不能够转换成数字,请重新输入");
            //        }
            //    }
            //    else//==q
            //    {
            //        Console.WriteLine("输入的是q,程序退出");
            //    }
            //}

            //练习5:不断要求用户输入一个数字(假定用户输入的都是正整数),当用户输入end的时候显示刚才输入的数字中的最大值
            //循环体:提示用户输入一个数字  接收  转换成int类型  不停的比较大小
            //循环条件:输入的不能是end
            //F11
            string input = "";
            int max = 0;
            while (input != "end")
            {
                Console.WriteLine("请输入一个数字,输入end我们将显示你输入的最大值");
                input = Console.ReadLine();//数字 end  乱七八糟
                if (input != "end")
                {
                    try
                    {
                        int number = Convert.ToInt32(input);
                        //让用户输入的每个数字都跟我假定的最大值比较,只要比我假定的最大值要大,
                        //就把当前输入的这个数字赋值给我的最大值
                        if (number > max)
                        {
                            max = number;
                        }
                    }
                    catch
                    {
                        Console.WriteLine("输入的字符串不能够转换成数字,请重新输入");
                    }

                }
                else//==end
                {
                    Console.WriteLine("您刚才输的数字中的最大值是{0}", max);
                }
            }
            Console.ReadKey();


            Console.ReadKey();

            //====== 调试

            Console.WriteLine("Hello World");
            Console.WriteLine("Hello World");
            Console.WriteLine("Hello World");
            Console.WriteLine("Hello World");
            Console.WriteLine("Hello World");
            Console.WriteLine("Hello World");
            Console.WriteLine("Hello World");

            //程序运行断点处,就不在向下执行了
            Console.WriteLine("这行代码有可能有错误");
            Console.WriteLine("这行代码有可能有错误");
            Console.WriteLine("这行代码有可能有错误");
            Console.WriteLine("这行代码有可能有错误");
            Console.WriteLine("这行代码有可能有错误");
            Console.WriteLine("Hello World");
            Console.WriteLine("Hello World");
            Console.WriteLine("Hello World");
            Console.WriteLine("Hello World");
            Console.WriteLine("Hello World");
            Console.WriteLine("Hello World");
            Console.WriteLine("Hello World");
            Console.WriteLine("Hello World");

            //====== for 循环

            //向控制台打印10遍  欢迎来到传智播客.Net学习

            for (int i = 0; i < 10; i++)
            {
                Console.WriteLine("欢迎来到传智播客.Net学习{0}", i);
            }
            //for (int i = 0; i < length; i++)
            //{

            //}
            Console.ReadKey();

            //int i = 0;//定义循环的次数
            //while (i < 10)
            //{
            //    Console.WriteLine("欢迎来到传智播客.Net学习");
            //    i++;
            //}
            //Console.ReadKey();

            //====== for循环的正序输出和倒序输出

            //请打印 1-10
            int i = 0;
            for (; i < 10;)
            {
                Console.WriteLine("欢迎来到传智播客.Net学习");
                i++;
            }
            Console.ReadKey();

            //for (int i = 1; i <= 10; i++)
            //{
            //    Console.WriteLine(i);
            //}
            ////打印10-1
            //for (int i = 10; i >= 1; i--)
            //{
            //    Console.WriteLine(i);
            //}

            //for (int i = 10; i >= 1; i--)
            //{
            //    Console.WriteLine(i);
            //}
            Console.ReadKey();

            //====== for循环练习

            //求1-100之间的所有整数和   偶数和  奇数和
            //int sum = 0;
            //int n = 100;
            //for (int i = 1; i <= n; i += 2)
            //{
            //    sum += i;
            //}
            //Console.WriteLine(sum);
            //Console.ReadKey();

            //找出100-999间的水仙花数?
            //水仙花数指的就是 这个百位数字的
            //百位的立方+十位的立方+个位的立方==当前这个百位数字
            //153  1 125  27  153  i
            //百位:153/100
            //十位:153%100/10
            //个位:153%10

            for (int i = 100; i <= 999; i++)
            {
                int bai = i / 100;
                int shi = i % 100 / 10;
                int ge = i % 10;
                if (bai * bai * bai + shi * shi * shi + ge * ge * ge == i)
                {
                    Console.WriteLine("水仙花数有{0}", i);
                }
            }
            Console.ReadKey();

            //====== for循环嵌套

            //当遇到某个事情要做一遍,而另外一个事情要做N遍的时候
            //for循环的嵌套
            for (int i = 0; i < 10; i++)
            {
                for (int j = 0; j < 10; j++)
                {
                    Console.WriteLine("Hello World i循环了{0}次,j循环了{1}次", i, j);
                    break;
                }
            }
            Console.ReadKey();

            //====== 乘法口决 

            //for (int i = 1; i <= 9; i++)
            //{
            //    for (int j = 1; j <= i; j++)
            //    {
            //        Console.Write("{0}*{1}={2}\t", i, j, i * j);
            //    }
            //    Console.WriteLine();//换行
            //}
            //Console.ReadKey();

            //Console.Write("Hello Wor\tld");
            //Console.WriteLine();
            //Console.Write("Hello World");
            //Console.ReadKey();

            Console.WriteLine("请输入一个数字");
            int number = Convert.ToInt32(Console.ReadLine());


            for (int i = 0; i <= number; i++)
            {
                Console.WriteLine("{0}+{1}={2}", i, number - i, number);
            }
            Console.ReadKey();

            //====== 类型转换
            //使用Convert进行转换 成功了就成了, 失败了就抛异常
            // int numberOne = Convert.ToInt32("123abc");

            // int number = int.Parse("123abc");

            //Console.WriteLine(number);
            int number = 100;
            //参数 返回值
            bool b = int.TryParse("123abc", out number);
            Console.WriteLine(b);
            Console.WriteLine(number);
            //方法 或者 函数?
            Console.ReadKey();

            //====== for循环3个练习

            //练习1:循环录入5个人的年龄并计算平均年龄,
            //如果录入的数据出现负数或大于100的数,立即停止输入并报错.
            //int sum = 0;
            //bool b = true;
            //for (int i = 0; i < 5; i++)
            //{
            //    Console.WriteLine("请输入第{0}个人的成绩",i+1);
            //    try
            //    {
            //        int age = Convert.ToInt32(Console.ReadLine());
            //        if (age >= 0 && age <= 100)
            //        {
            //            sum += age;
            //        }
            //        else
            //        {
            //            Console.WriteLine("输入的年龄不在正确范围内,程序退出!!!");
            //            b = false;
            //            break;
            //        }
            //    }
            //    catch
            //    {
            //        Console.WriteLine("输入的年龄不正确,程序退出!!!");
            //        b = false;
            //        break;
            //    }
            //}
            //if (b)
            //{
            //    Console.WriteLine("5个人的平均年龄是{0}", sum / 5);
            //}
            //Console.ReadKey();


            //     练习2:在while中用break实现要求用户一直输入用户名和密码,
            //只要不是admin、88888就一直提示要求重新输入,如果正确则提登录成功.
            //string name = "";
            //string pwd = "";
            //while (true)
            //{
            //    Console.WriteLine("请输入用户名");
            //    name = Console.ReadLine();
            //    Console.WriteLine("请输入密码");
            //    pwd = Console.ReadLine();

            //    if (name == "admin" && pwd == "888888")
            //    {
            //        Console.WriteLine("登陆成功");
            //        break;
            //    }
            //    else
            //    {
            //        Console.WriteLine("用户名或密码错误,请重新输入");
            //    }
            //}
            //Console.ReadKey();


            //1~100之间的整数相加,得到累加值大于20的当前数
            //(比如:1+2+3+4+5+6=21)结果6 sum>=20  i
            int sum = 0;
            for (int i = 1; i <= 100; i++)
            {
                sum += i;
                if (sum >= 20)
                {
                    Console.WriteLine("加到{0}的时候,总和大于了20", i);
                    break;
                }
            }
            Console.ReadKey();

            //====== continue
            /*
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _10continue
    {
        class Program
        {
            static void Main(string[] args)
            {
                while (true)
                {
                    Console.WriteLine("Hello World");
                    // break;
                    continue;
                    Console.WriteLine("Hello World");
                    Console.WriteLine("Hello World");
                }
                Console.ReadKey();
            }
        }
    }
            */
            //====== continue 练习

            //练习1:用 while continue实现计算1到100(含)之间的除了能被7整除之外所有整数的和。

            //int sum = 0;
            //int i=1;
            //while (i <= 100)
            //{
            //    if (i % 7 == 0)
            //    {
            //        i++;
            //        continue;
            //    }
            //    sum += i;
            //    i++;
            //}
            //Console.WriteLine(sum);
            //Console.ReadKey();


            //找出100内所有的素数
            //素数/质数:只能被1和这个数字本身整除的数字
            //2 3  4  5  6  7
            //7   7%1   7%2 7%3 7%4 7%5 7%6  7%7  6%2

            for (int i = 2; i <= 100; i++)
            {
                bool b = true;
                for (int j = 2; j < i; j++)
                {
                    //除尽了说明不是质数 也就没有再往下继续取余的必要了
                    if (i % j == 0)
                    {
                        b = false;
                        break;
                    }
                }

                if (b)
                {
                    Console.WriteLine(i);
                }
            }

            Console.ReadKey();
            //6   6%2 6%3

            //====== 三元表达式

            ////计算两个数字的大小 求出最大的
            //Console.WriteLine("请输入第一个数字");
            //int n1 = Convert.ToInt32(Console.ReadLine());
            //Console.WriteLine("请输入第二个数字");
            //int n2 = Convert.ToInt32(Console.ReadLine());
            ////            语法:
            ////表达式1?表达式2 :表达式3
            //int max = n1 > n2 ? n1 : n2;
            //Console.WriteLine(max);
            ////if (n1 > n2)
            ////{
            ////    Console.WriteLine(n1);
            ////}
            ////else
            ////{
            ////    Console.WriteLine(n2);
            ////}
            //Console.ReadKey();


            //提示用户输入一个姓名 只要输入的不是老赵  就全是流氓
            Console.WriteLine("请输入姓名");
            string name = Console.ReadLine();

            string result = name == "老赵" ? "淫才呀" : "流氓呀";
            Console.WriteLine(result);
            Console.ReadKey();

            //if (name == "老赵")
            //{
            //    Console.WriteLine("淫才呀");
            //}
            //else
            //{
            //    Console.WriteLine("流氓呀");
            //}
            Console.ReadKey();


            //====== 
            /*
            using System;
            using System.Collections.Generic;
            using System.Linq;
            using System.Text;
            using System.Threading.Tasks;

            namespace _13_随机数
            {
            class Program
            {
            static void Main(string[] args)
            {
                //产生随机数
                //1、创建能够产生随机数的对象
                //Random r = new Random();
                //while (true)
                //{

                //    //2、让产生随机数的这个对象调用方法来产生随机数
                //    int rNumber = r.Next(1, 11);
                //    Console.WriteLine(rNumber);
                //    Console.ReadKey();
                //}

                //输入名字随机显示这个人上辈是什么样的人
                //思路:
                //1、创建能够产生随机数的对象
                //2、产生随机数 (1,7)

                Random r = new Random();
                while (true)
                {
                    int rNumber = r.Next(1, 7);
                    Console.WriteLine("请输入一个姓名");
                    string name = Console.ReadLine();
                    switch (rNumber)
                    {
                        case 1:
                            Console.WriteLine("{0}上辈子是吃翔的", name);
                            break;
                        case 2:
                            Console.WriteLine("{0}上辈子是拉翔的", name);
                            break;
                        case 3:
                            Console.WriteLine("{0}上辈子就是一坨翔", name);
                            break;
                        case 4:
                            Console.WriteLine("{0}上辈子是大汉奸", name);
                            break;
                        case 5:
                            Console.WriteLine("{0}上辈子是拉皮条的", name);
                            break;
                        case 6:
                            Console.WriteLine("{0}上辈子是救苦救难的活菩萨", name);
                            break;
                    }
                    Console.ReadKey();
                }

            }
            }
            }
            */

            //====== 复习
            /*
            using System;
            using System.Collections.Generic;
            using System.Linq;
            using System.Text;
            using System.Threading.Tasks;

            namespace _01复习
            {
            class Program
            {
            static void Main(string[] args)
            {
                int number = 10;
                number = 20;//体现了变量可以被重新赋值

                const int numberTwo = 50;//常量 不能够被重新赋值
                                         //numberTwo = 90;
            }
            }
            }
            */

            //====== 枚举
            /*
            using System;
            using System.Collections.Generic;
            using System.Linq;
            using System.Text;
            using System.Threading.Tasks;

            namespace _02枚举
            {
            //
            //    [public] enum 枚举名
            //{
            //    值1,
            //    值2,
            //    值3,
            //    ........
            //}


            //声明了一个枚举 Gender
            public enum Gender
            {
            男,
            女
            }

            class Program
            {

            static void Main(string[] args)
            {
                //变量类型 变量名=值;
                int n = 10;
                Gender gender = Gender.男;

                //为什么会有枚举这个东东?
                //xx大学管理系统
                //姓名 性别 年龄 系别 年级  
                //性别
                //char gender = '男';
                //string s1 = "female";
                //string ss1 = "爷们";
            }
            }
            }
            */

            //====== 枚举的练习
            /*
            using System;
            using System.Collections.Generic;
            using System.Linq;
            using System.Text;
            using System.Threading.Tasks;

            namespace _03枚举的练习
            {
            public enum Sesons
            {
            春,
            夏,
            秋,
            冬
            }

            public enum QQState
            {
            OnLine,
            OffLine,
            Leave,
            Busy,
            QMe
            }


            class Program
            {
            static void Main(string[] args)
            {
                Sesons s = Sesons.春;
                QQState state = QQState.OnLine;

            }
            }
            }
            */

            //====== 枚举和int以及string类型之间的转换
            /*
            using System;
            using System.Collections.Generic;
            using System.Linq;
            using System.Text;
            using System.Threading.Tasks;

            namespace _04枚举和int以及string类型之间的转换
            {
            public enum QQState
            {
            OnLine = 1,
            OffLine,
            Leave,
            Busy,
            QMe
            }

            public enum Gender
            {
            男,
            女
            }
            class Program
            {
            static void Main(string[] args)
            {
                #region 将枚举类型强转成int类型
                //QQState state = QQState.OnLine;
                ////枚举类型默认可以跟int类型互相转换  枚举类型跟int类型是兼容的
                //int n = (int)state;
                //Console.WriteLine(n);
                //Console.WriteLine((int)QQState.OffLine);
                //Console.WriteLine((int)QQState.Leave);
                //Console.WriteLine((int)QQState.Busy);
                //Console.WriteLine((int)QQState.QMe);
                //Console.ReadKey();
                #endregion
                #region 将int类型强转为枚举类型

                //int n1 = 3;

                //QQState state = (QQState)n1;
                //Console.WriteLine(state);
                //Console.ReadKey();
                #endregion
                #region 将枚举类型转换成字符串类型
                //所有的类型都能够转换成string类型
                // int n1 = 10;
                //// double n1 = 3.14;
                // decimal n1 = 5000m;
                // string s = n1.ToString();
                // Console.WriteLine(s);
                // Console.ReadKey();

                //QQState state = QQState.OnLine;
                //string s = state.ToString();
                //Console.WriteLine(s);
                //Console.ReadKey();
                #endregion
                #region 将字符串类型转换为枚举类型
                //string s = "ABCDEFG";
                ////将s转换成枚举类型
                ////Convert.ToInt32()  int.parse()  int.TryParse()
                ////调用Parse()方法的目的就是为了让它帮助我们将一个字符串转换成对应的枚举类型
                ////
                //QQState state = (QQState)Enum.Parse(typeof(QQState), s);
                //Console.WriteLine(state);
                //Console.ReadKey();
                #endregion



                //枚举练习
                //提示用户选择一个在线状态,我们接受,并将用户的输入转换成枚举类型。
                //再次打印到控制台中

                Console.WriteLine("请选择您的qq在线状态 1--OnLine 2--OffLine 3--Leave 4--Busy 5--QMe");
                string input = Console.ReadLine();
                switch (input)
                {
                    case "1":
                        QQState s1 = (QQState)Enum.Parse(typeof(QQState), input);
                        Console.WriteLine("您选择的在线状态是{0}", s1);
                        break;
                    case "2":
                        QQState s2 = (QQState)Enum.Parse(typeof(QQState), input);
                        Console.WriteLine("您选择的在线状态是{0}", s2);
                        break;
                    case "3":
                        QQState s3 = (QQState)Enum.Parse(typeof(QQState), input);
                        Console.WriteLine("您选择的在线状态是{0}", s3);
                        break;
                    case "4":
                        QQState s4 = (QQState)Enum.Parse(typeof(QQState), input);
                        Console.WriteLine("您选择的在线状态是{0}", s4);
                        break;
                    case "5":
                        QQState s5 = (QQState)Enum.Parse(typeof(QQState), input);
                        Console.WriteLine("您选择的在线状态是{0}", s5);
                        break;
                }
                Console.ReadKey();
            }
            }
            }
            */
            //====== 结构
            /*
            using System;
            using System.Collections.Generic;
            using System.Linq;
            using System.Text;
            using System.Threading.Tasks;

            namespace _05结构
            {
            public struct Person
            {
            public string _name;//字段
            public int _age;
            public Gender _gender;
            }

            public enum Gender
            {
            男,
            女
            }

            class Program
            {
            static void Main(string[] args)
            {
                //XX大学管理系统
                //姓名、性别、年龄、年级  //5000  20000
                //string zsName = "张三";
                //int zsAge = 21;
                //char zsGender = '男';
                //int zsGrade = 3;

                string s = "123";

                Person zsPerson;
                zsPerson._name = "张三";
                zsPerson._age = 21;
                zsPerson._gender = Gender.男;


                Person lsPerson;
                lsPerson._name = "李四";
                lsPerson._age = 22;
                lsPerson._gender = Gender.女;


                Console.WriteLine(zsPerson._name);
                Console.WriteLine(lsPerson._name);
                Console.ReadKey();

            }
            }
            }
            */

            //====== 结构练习
            /*
            using System;
            using System.Collections.Generic;
            using System.Linq;
            using System.Text;
            using System.Threading.Tasks;

            namespace _06结构练习
            {

            public struct MyColor
            {
            public int _red;
            public int _green;
            public int _blue;
            }


            public enum Gender
            {
            男,
            女
            }


            public struct Person
            {
            public string _name;
            public int _age;
            public Gender _gender;
            }




            class Program
            {
            static void Main(string[] args)
            {
                //1 定义一个结构叫MyColor,有三个成员,分别定义为int类型的red,green,blue
                //声明一个 MyColor类型的变量,并对其成员赋值.使MyColor可以表示成一个红色.
                //MyColor mc;
                //mc._red = 255;
                //mc._blue = 0;
                //mc._green = 0;


                //2 定义一个结构类型Person,有三个成员,分别为姓名,性别,年龄 性别用枚举类型
                //声明两个Person类型的变量,分别表示 张三 男  18岁/ 小兰 女 16岁


                Person zsPerson;
                zsPerson._name = "张三";
                zsPerson._gender = Gender.男;
                zsPerson._age = 18;


                Person xlPerson;
                xlPerson._name = "小兰";
                xlPerson._gender = Gender.女;
                xlPerson._age = 16;


                Console.WriteLine("我叫{0},我今年{1}岁了,我是{2}生", zsPerson._name, zsPerson._age, zsPerson._gender);
                Console.WriteLine("我叫{0},我今年{1}岁了,我是{2}生", xlPerson._name, xlPerson._age, xlPerson._gender);
                Console.ReadKey();

            }
            }
            }
            */
            //====== 数组

            /*
            //数组类型[] 数组名=new 数组类型[数组长度];
            int[] nums = new int[10];
            //数组的声明方式
            int[] numsTwo = { 1, 2, 3, 4, 5, 6 };
            //string[] str = new string[10];
            ////null ""
            //bool[] bools = new bool[10];
            //Console.ReadKey();
            //nums[0] = 1;
            //nums[1] = 2;
            //nums[2] = 3;
            //nums[3] = 4;
            //nums[4] = 5;
            //nums[5] = 6;
            //nums[6] = 7;
            //nums[7] = 8;
            //nums[8] = 9;
            //nums[9] = 10;
            //nums[10] = 11;
            ////我们通过一个循环给数组赋值,同样,也通过一个循环对数组进行取值
            ////for (int i = 0; i < nums.Length; i++)
            ////{
            ////    nums[i] = i;
            ////}
            //for (int i = 0; i < nums.Length; i++)
            //{
            //    Console.WriteLine(nums[i]);
            //}
            Console.ReadKey();

            //====== 数组的5个练习

            #region 练习1
            ////练习1:从一个整数数组中取出最大的整数,最小整数,总和,平均值
            ////声明一个int类型的数组 并且随意的赋初值
            //int[] nums = { 1, 2, 3, 4, 5, 6, 7, 8, 9 };
            ////声明两个变量用来存储最大值和最小值
            //int max = int.MinValue;//nums[3];
            //int min = int.MaxValue;//nums[0];
            //int sum = 0;
            ////循环的让数组中的每个元素跟我的最大值、最小值进行比较

            //for (int i = 0; i < nums.Length; i++)
            //{
            //    //关于在循环中nums[i]的理解方式
            //    //1、代表数组中当前循环到的元素
            //    //2、代表数组中的每个元素
            //    //如果数组中当前循环到的这个元素 比我的max还要大,则把当前这个元素赋值给我的max
            //    if (nums[i] > max)
            //    {
            //        max = nums[i];
            //    }

            //    if (nums[i] < min)
            //    {
            //        min = nums[i];
            //    }
            //    sum += nums[i];
            //}
            //Console.WriteLine("这个数组的最大值是{0},最小值是{1},总和是{2},平均值是{3}", max, min, sum, sum / nums.Length);
            //Console.ReadKey(); 
            #endregion



            //练习3:数组里面都是人的名字,分割成:例如:老杨|老苏|老邹…”
            //(老杨,老苏,老邹,老虎,老牛,老蒋,老王,老马)

            //string[] names = { "老杨", "老苏", "老邹", "老虎", "老牛", "老马" };
            ////老杨|老苏|老邹|老虎|老牛|老马
            ////解体思路:通过一个循环,获得字符串数组中的每一个元素。
            ////然后,将这个每一个元素都累加到一个字符串中,以|分割
            //string str=null;//""
            //for (int i = 0; i < names.Length-1; i++)
            //{
            //    str += names[i]+"|";
            //}
            //Console.WriteLine(str+names[names.Length-1]);
            //Console.ReadKey();


            #region 练习4
            //练习4:将一个整数数组的每一个元素进行如下的处理:
            //如果元素是正数则将这个位置的元素的值加1,
            //如果元素是负数则将这个位置的元素的值减1,如果元素是0,则不变。

            //int[] nums = { 1, -2, 3, -4, 5, 6, 0 };
            ////解题思路:通过一个循环,获得数组中的每一个元素。
            ////对每一个元素进行判断
            //for (int i = 0; i < nums.Length; i++)
            //{
            //    if (nums[i] > 0)
            //    {
            //        nums[i] += 1;
            //    }
            //    else if (nums[i] < 0)
            //    {
            //        nums[i] -= 1;
            //    }
            //    else
            //    {
            //        //nums[i] = 0;
            //    }
            //}

            //for (int i = 0; i < nums.Length; i++)
            //{
            //    Console.WriteLine(nums[i]);
            //}
            //Console.ReadKey();

            #endregion



            //练习5:将一个字符串数组的元素的顺序进行反转。{“我”,“是”,”好人”} {“好人”,”是”,”我”}。第i个和第length-i-1个进行交换。
            string[] names = { "a", "b", "c", "d", "e", "f", "g" };
            for (int i = 0; i < names.Length / 2; i++)
            {
                string temp = names[i];
                names[i] = names[names.Length - 1 - i];
                names[names.Length - 1 - i] = temp;
            }

            for (int i = 0; i < names.Length; i++)
            {
                Console.WriteLine(names[i]);
            }
            Console.ReadKey();


            //{"好人","是","我"};
            */

            //====== 冒泡非序
            /*
            int[] nums = { 1, 4, 3, 9, 6, 8, 11 };
            //只能针对数组做一个升序的排列
            //Array.Sort(nums);

            //对数组进行反转
            Array.Reverse(nums);

            //for (int i = 0; i < nums.Length - 1; i++)
            //{
            //    for (int j = 0; j < nums.Length - 1-i ; j++)
            //    {
            //        if (nums[j] > nums[j + 1])
            //        {
            //            int temp = nums[j];
            //            nums[j] = nums[j + 1];
            //            nums[j + 1] = temp;
            //        }
            //    }
            //}


            for (int i = 0; i < nums.Length; i++)
            {
                Console.WriteLine(nums[i]);
            }
            Console.ReadKey();
            */

            //====== 方法
            /*
            using System;
            using System.Collections.Generic;
            using System.Linq;
            using System.Text;
            using System.Threading.Tasks;

            namespace _10方法
            {
            class Program
            {
            static void Main(string[] args)
            {
                //闪烁  播放一段特殊的背景音乐  屏幕停止
                Program.PlayGame();
                Program.WuDi();
                Program.PlayGame();
                Program.PlayGame();
                Program.PlayGame();
                Program.PlayGame();
                Program.WuDi();
                Console.ReadKey();


            }

            /// <summary>
            /// 正常玩游戏
            /// </summary>
            public static void PlayGame()
            {
                Console.WriteLine("超级玛丽走呀走,跳呀跳,顶呀顶");
                Console.WriteLine("超级玛丽走呀走,跳呀跳,顶呀顶");
                Console.WriteLine("超级玛丽走呀走,跳呀跳,顶呀顶");
                Console.WriteLine("超级玛丽走呀走,跳呀跳,顶呀顶");
                Console.WriteLine("超级玛丽走呀走,跳呀跳,顶呀顶");
                Console.WriteLine("突然,顶到了一个无敌");
            }
            /// <summary>
            /// 无敌
            /// </summary>
            public static void WuDi()
            {
                Console.WriteLine("屏幕开始闪烁");
                Console.WriteLine("播放无敌的背景音乐");
                Console.WriteLine("屏幕停止");
            }

            }
            }
            */
            //====== 方法练习
            /*
            using System;
            using System.Collections.Generic;
            using System.Linq;
            using System.Text;
            using System.Threading.Tasks;

            namespace _11_方法练习
            {
            class Program
            {
            static void Main(string[] args)
            {
                //计算两个整数之间的最大值
                int max = Program.GetMax(1, 3);
                Console.WriteLine(max);
                // Array.Sort()
                // int n = Convert.ToInt32("123");

                string str = Console.ReadLine();

                Console.ReadKey();
            }


            /// <summary>
            /// 计算两个整数之间的最大值并且将最大值返回
            /// </summary>
            /// <param name="n1">第一个整数</param>
            /// <param name="n2">第二个整数</param>
            /// <returns>将最大值返回</returns>
            public static int GetMax(int n1, int n2)
            {
                return n1 > n2 ? n1 : n2;
            }

            }
            }
            */

            //====== return
            /*
             using System;
            using System.Collections.Generic;
            using System.Linq;
            using System.Text;
            using System.Threading.Tasks;

            namespace _12_return
            {
            class Program
            {
                static void Main(string[] args)
                {

                    while (true)
                    {
                        Console.WriteLine("Hello World");
                        //break;
                       // continue;
                        return;
                    }
                    Console.WriteLine("Hello .Net");
                    Console.ReadKey();
                }
            }
            }
            */

            //====== 复习
            /*
             using System;
            using System.Collections.Generic;
            using System.Linq;
            using System.Text;
            using System.Threading.Tasks;

            namespace _01复习
            {
                public enum Gender
                {
                    男,
                    女
                }

                public struct Person
                {
                    public string _name;
                    public int _age;
                    public Gender _gender;
                }

                class Program
                {
                    static void Main(string[] args)
                    {

                        //Person zsPerson;
                        //zsPerson._name = "张三";
                        //zsPerson._age = 20;
                        //zsPerson._gender = Gender.男;

                        //Gender gender = Gender.男;
                        //string s = "男";

                        //Gender g = (Gender)Enum.Parse(typeof(Gender), s);
                        //Console.WriteLine(g);
                        //Console.ReadKey();


                        //常量  枚举  结构  数组
                        //  const int number = 10;


                        //数组 可以一次性的存储多个相同类型的变量
                      //  int[] numbers = new int[10];

                       // numbers[20] = 3;

                        //冒泡排序


                        int[] numbers = { 11, 2, 55, 64, 3, 9, 17 };
                        //升序排列
                        Array.Sort(numbers);
                        Array.Reverse(numbers);
                        for (int i = 0; i < numbers.Length; i++)
                        {
                            Console.WriteLine(numbers[i]);
                        }
                        Console.ReadKey();

                        //for (int i = 0; i < numbers.Length-1; i++)
                        //{
                        //    for (int j = 0; j < numbers.Length-1-i; j++)
                        //    {
                        //        if (numbers[j] < numbers[j + 1])
                        //        {
                        //            int temp = numbers[j];
                        //            numbers[j] = numbers[j + 1];
                        //            numbers[j + 1] = temp;
                        //        }
                        //    }
                        //}

                        //for (int i = 0; i < numbers.Length; i++)
                        //{
                        //    Console.WriteLine(numbers[i]);
                        //}
                        Console.ReadKey();


                    }
                }
            }
            */

            //====== 方法的调用问题
            /*
                        using System;
                        using System.Collections.Generic;
                        using System.Linq;
                        using System.Text;
                        using System.Threading.Tasks;

            namespace _02方法的调用问题
                {
                    class Program
                    {
                        //字段 属于类的字段
                        public static int _number = 10;


                        static void Main(string[] args)
                        {
                            //  int b = 10;
                            int a = 3;
                            int res = Test(a);
                            Console.WriteLine(res);
                            // Console.WriteLine(_number);
                            Console.ReadKey();
                        }
                        public static int Test(int a)
                        {
                            a = a + 5;
                            return a;
                            //  Console.WriteLine(_number);
                        }


                        public static void TestTwo()
                        {
                            // Console.WriteLine(_number);
                        }
                    }
                }
            */
            //====== 判断闰年
            /*
            using System;
            using System.Collections.Generic;
            using System.Linq;
            using System.Text;
            using System.Threading.Tasks;

            namespace _03判断闰年
            {
            class Program
            {
            static void Main(string[] args)
            {
                //举例:写一个方法,判断一个年份是否是润年.

                bool b = IsRun(2000);
                Console.WriteLine(b);
                Console.ReadKey();

            }
            /// <summary>
            /// 判断给定的年份是否是闰年
            /// </summary>
            /// <param name="year">要判断的年份</param>
            /// <returns>是否是闰年</returns>
            public static bool IsRun(int year)
            {
                bool b = (year % 400 == 0) || (year % 4 == 0 && year % 100 != 0);
                return b;
            }


            }
            }
            */
            //====== 方法的概念

            /*
            using System;
            using System.Collections.Generic;
            using System.Linq;
            using System.Text;
            using System.Threading.Tasks;

            namespace _04方法概念
            {
            class Program
            {
            public static void Main(string[] args)
            {
                //比较两个数字的大小 返回最大的
                //int a1 = 10;
                //int a2 = 20;
                int max = GetMax(10, 20);//实参
                Console.WriteLine(max);
                Console.ReadKey();
            }


            /// <summary>
            /// 计算两个整数之间的最大值 并且返回最大值
            /// </summary>
            /// <param name="n1">第一个数</param>
            /// <param name="n2">第二个数</param>
            /// <returns>返回的最大值</returns>
            public static int GetMax(int n1, int n2)//形参
            {
                int max = n1 > n2 ? n1 : n2;

                return max;
            }
            }
            }
            */

            //====== 方法的练习
            /*
            using System;
            using System.Collections.Generic;
            using System.Linq;
            using System.Text;
            using System.Threading.Tasks;

            namespace _05方法练习
            {
            class Program
            {
            static void Main(string[] args)
            {
                //1 读取输入的整数
                //多次调用(如果用户输入的是数字,则返回,否则提示用户重新输入)

                Console.WriteLine("请输入一个数字");
                string input = Console.ReadLine();
                int number = GetNumber(input);
                Console.WriteLine(number);
                Console.ReadKey();
            }

            /// <summary>
            /// 这个方法需要判断用户的输入是否是数字
            /// 如果是数字,则返回
            /// 如果不是数字,提示用户重新输入
            /// </summary>
            public static int GetNumber(string s)
            {
                while (true)
                {
                    try
                    {
                        int number = Convert.ToInt32(s);
                        return number;
                    }
                    catch
                    {
                        Console.WriteLine("请重新输入");
                        s = Console.ReadLine();
                    }
                }
            }


            }
            }
            */
            //====== 方法的3个练习
            /*
            using System;
            using System.Collections.Generic;
            using System.Linq;
            using System.Text;
            using System.Threading.Tasks;

            namespace _06方法的3个练习
            {
            class Program
            {
            static void Main(string[] args)
            {
                //2 还记得学循环时做的那道题吗?只允许用户输入y或n,请改成方法

                //这个方法做了什么事儿?
                //只能让用户输入yes或者no,只要不是,就重新输入

                //输入yes 看 输入no 不能看   

                //Console.WriteLine("请输入yes或者no");
                //string str = Console.ReadLine();
                //string result = IsYerOrNo(str);
                //Console.WriteLine(result);
                //Console.ReadKey();

                //4计算输入数组的和:int Sum(int[] values)
                int[] nums = { 1, 2, 3, 4, 5, 6, 7, 8, 9 };
                int sum = GetSum(nums);
                Console.WriteLine(sum);
                Console.ReadKey();
            }

            /// <summary>
            /// 计算一个整数类型数组的总和
            /// </summary>
            /// <param name="nums">要求总和的数组</param>
            /// <returns>返回这个数组的总和</returns>
            public static int GetSum(int[] nums)
            {
                int sum = 0;
                for (int i = 0; i < nums.Length; i++)
                {
                    sum += nums[i];
                }
                return sum;
            }



            /// <summary>
            /// 限定用户只能输入yes或者no 并且返回
            /// </summary>
            /// <param name="input">用户的输入</param>
            /// <returns>返回yes或者no</returns>
            public static string IsYerOrNo(string input)
            {
                while (true)
                {
                    if (input == "yes" || input == "no")
                    {
                        return input;
                    }
                    else
                    {
                        Console.WriteLine("只能输入yes或者no,请重新输入");
                        input = Console.ReadLine();
                    }
                }
            }
            }
            }
            */

            //====== out 参数
            /*
            using System;
            using System.Collections.Generic;
            using System.Linq;
            using System.Text;
            using System.Threading.Tasks;

            namespace _07out参数
            {
            class Program
            {
            static void Main(string[] args)
            {
                //写一个方法 求一个数组中的最大值、最小值、总和、平均值
                int[] numbers = { 1, 2, 3, 4, 5, 6, 7, 8, 9 };
                ////将要返回的4个值,放到一个数组中返回

                //int[] res = GetMaxMinSumAvg(numbers);
                //Console.WriteLine("最大值是{0},最小值是{1},总和是{2},平均值是{3}", res[0], res[1], res[2], res[3]);
                //Console.ReadKey();
                int max1;
                int min1;
                int sum1;
                int avg1;
                bool b;
                string s;
                double d;
                Test(numbers, out max1, out min1, out sum1, out avg1, out b, out s, out d);

                Console.WriteLine(max1);
                Console.WriteLine(min1);
                Console.WriteLine(sum1);
                Console.WriteLine(avg1);
                Console.WriteLine(b);
                Console.WriteLine(s);
                Console.WriteLine(d);
                Console.ReadKey();

            }
            /// <summary>
            /// 计算一个数组的最大值、最小值、总和、平均值
            /// </summary>
            /// <param name="nums"></param>
            /// <returns></returns>
            public static int[] GetMaxMinSumAvg(int[] nums)
            {
                int[] res = new int[4];
                //假设 res[0] 最大值  res[1]最小值  res[2]总和  res[3]平均值
                res[0] = nums[0];//max
                res[1] = nums[0];//min
                res[2] = 0;//sum
                string name = "孙全";
                bool b = true;
                for (int i = 0; i < nums.Length; i++)
                {
                    //如果当前循环到的元素比我假定的最大值还大 
                    if (nums[i] > res[0])
                    {
                        //将当前循环到的元素赋值给我的最大值
                        res[0] = nums[i];
                    }
                    if (nums[i] < res[1])
                    {
                        res[1] = nums[i];
                    }
                    res[2] += nums[i];
                }
                //平均值
                res[3] = res[2] / nums.Length;
                return res;


            }


            /// <summary>
            /// 计算一个整数数组的最大值、最小值、平均值、总和
            /// </summary>
            /// <param name="nums">要求值得数组</param>
            /// <param name="max">多余返回的最大值</param>
            /// <param name="min">多余返回的最小值</param>
            /// <param name="sum">多余返回的总和</param>
            /// <param name="avg">多余返回的平均值</param>
            public static void Test(int[] nums, out int max, out int min, out int sum, out int avg, out bool b, out string s, out double d)
            {
                //out参数要求在方法的内部必须为其赋值
                max = nums[0];
                min = nums[0];
                sum = 0;
                for (int i = 0; i < nums.Length; i++)
                {
                    if (nums[i] > max)
                    {
                        max = nums[i];
                    }
                    if (nums[i] < min)
                    {
                        min = nums[i];
                    }
                    sum += nums[i];
                }
                avg = sum / nums.Length;


                b = true;
                s = "123";
                d = 3.13;
            }



            }
            }
            */
            //====== 使用out 做登陆
            /*
            using System;
            using System.Collections.Generic;
            using System.Linq;
            using System.Text;
            using System.Threading.Tasks;

            namespace _08使用out参数做登陆
            {
            class Program
            {
            static void Main(string[] args)
            {
                //分别的提示用户输入用户名和密码
                //你写一个方法来判断用户输入的是否正确
                //返回给用户一个登陆结果,并且还要单独的返回给用户一个登陆信息
                //如果用户名错误,除了返回登陆结果之外,还要返回一个 "用户名错误"
                //“密码错误”
                Console.WriteLine("请输入用户名");
                string userName = Console.ReadLine();
                Console.WriteLine("请输入密码");
                string userPwd = Console.ReadLine();
                string msg;
                bool b = IsLogin(userName, userPwd, out msg);
                Console.WriteLine("登陆结果{0}", b);
                Console.WriteLine("登陆信息{0}", msg);
                Console.ReadKey();
            }

            /// <summary>
            /// 判断登陆是否成功
            /// </summary>
            /// <param name="name">用户名</param>
            /// <param name="pwd">密码</param>
            /// <param name="msg">多余返回的登陆信息</param>
            /// <returns>返回登陆结果</returns>
            public static bool IsLogin(string name, string pwd, out string msg)
            {
                if (name == "admin" && pwd == "888888")
                {
                    msg = "登陆成功";
                    return true;
                }
                else if (name == "admin")
                {
                    msg = "密码错误";
                    return false;
                }
                else if (pwd == "888888")
                {
                    msg = "用户名错误";
                    return false;
                }
                else
                {
                    msg = "未知错误";
                    return false;
                }
            }
            }
            }
            */
            //====== 自己动手写tryparse
            /*
            using System;
            using System.Collections.Generic;
            using System.Linq;
            using System.Text;
            using System.Threading.Tasks;

            namespace _09自己动手写tryparse
            {
            class Program
            {
            static void Main(string[] args)
            {
                int num;
                bool b = int.TryParse("123abc", out num);
                Console.WriteLine(num);
                Console.WriteLine(b);
                Console.ReadKey();
            }

            public static bool MyTryParse(string s, out int result)
            {
                result = 0;
                try
                {
                    result = Convert.ToInt32(s);
                    return true;
                }
                catch
                {
                    return false;
                }
            }


            }
            }
            */
            //====== ref 参数
            /*
            using System;
            using System.Collections.Generic;
            using System.Linq;
            using System.Text;
            using System.Threading.Tasks;

            namespace _10ref参数
            {
            class Program
            {
            static void Main(string[] args)
            {
                double salary = 5000;
                JiangJin(ref salary);
                Console.WriteLine(salary);
                Console.ReadKey();
            }

            public static void JiangJin(ref double s)
            {
                s += 500;

            }

            public static void FaKuan(double s)
            {
                s -= 500;
            }
            }
            }
            */

            //====== ref练习
            /*
            using System;
            using System.Collections.Generic;
            using System.Linq;
            using System.Text;
            using System.Threading.Tasks;

            namespace _11_ref练习
            {
            class Program
            {
            static void Main(string[] args)
            {
                //使用方法来交换两个int类型的变量
                int n1 = 10;
                int n2 = 20;
                //int temp = n1;
                //n1 = n2;
                //n2 = temp;
                Test(ref n1, ref n2);
                Console.WriteLine(n1);
                Console.WriteLine(n2);
                Console.ReadKey();
                //n1 = n1 - n2;//-10 20
                //n2 = n1 + n2;//-10 10
                //n1 = n2 - n1;//20 10

            }


            public static void Test(ref int n1, ref int n2)
            {
                int temp = n1;
                n1 = n2;
                n2 = temp;
            }
            }
            }
            */
            //====== params可变参数
            /*
            using System;
            using System.Collections.Generic;
            using System.Linq;
            using System.Text;
            using System.Threading.Tasks;

            namespace _12params可变参数
            {
            class Program
            {
            static void Main(string[] args)
            {
                //   int[] s = { 99, 88, 77 };
                //Test("张三",99,100,100,100);
                //Console.ReadKey();

                //求任意长度数组的和 整数类型的
                int[] nums = { 1, 2, 3, 4, 5 };
                int sum = GetSum(8, 9);
                Console.WriteLine(sum);
                Console.ReadKey();
            }

            public static int GetSum(params int[] n)
            {
                int sum = 0;
                for (int i = 0; i < n.Length; i++)
                {
                    sum += n[i];
                }
                return sum;
            }


            public static void Test(string name, int id, params int[] score)
            {
                int sum = 0;

                for (int i = 0; i < score.Length; i++)
                {
                    sum += score[i];
                }
                Console.WriteLine("{0}这次考试的总成绩是{1},学号是{2}", name, sum, id);
            }
            }
            }
            */

            //====== 方法的重载
            /*
            using System;
            using System.Collections.Generic;
            using System.Linq;
            using System.Text;
            using System.Threading.Tasks;

            namespace _13_方法的重载
            {
            class Program
            {
            static void Main(string[] args)
            {
                //   M()

                Console.WriteLine(1);
                Console.WriteLine(1.4);
                Console.WriteLine(true);
                Console.WriteLine('c');
                Console.WriteLine("123");
                Console.WriteLine(5000m);
                Console.ReadKey();
            }
            public static void M(int n1, int n2)
            {
                int result = n1 + n2;
            }
            //public static int M(int a1, int a2)
            //{
            //    return a1 + a2;
            //}
            public static double M(double d1, double d2)
            {
                return d1 + d2;
            }
            public static void M(int n1, int n2, int n3)
            {
                int result = n1 + n2 + n3;
            }
            public static string M(string s1, string s2)
            {
                return s1 + s2;
            }


            }
            }
            */
            //====== 方法的递归
            /*
            using System;
            using System.Collections.Generic;
            using System.Linq;
            using System.Text;
            using System.Threading.Tasks;

            namespace _14_方法的递归
            {
            class Program
            {
            static void Main(string[] args)
            {
                TellStory();
                Console.ReadKey();
            }

            public static int i = 0;


            public static void TellStory()
            {
                //int i = 0;
                Console.WriteLine("从前有座山");
                Console.WriteLine("山里有座庙");
                Console.WriteLine("庙里有个老和尚和小和尚");
                Console.WriteLine("有一天,小和尚哭了,老和尚给小和尚讲了一个故事");
                i++;
                if (i >= 10)
                {
                    return;
                }
                TellStory();

            }
            }
            }
            */
            //====== 方法的练习
            /*
            using System;
            using System.Collections.Generic;
            using System.Linq;
            using System.Text;
            using System.Threading.Tasks;

            namespace _15方法练习
            {
            class Program
            {
            static void Main(string[] args)
            {
                //            提示用户输入两个数字  计算这两个数字之间所有整数的和
                //1、用户只能输入数字
                //2、计算两个数字之间和
                //3、要求第一个数字必须比第二个数字小  就重新输入
                Console.WriteLine("请输入第一个数字");
                string strNumberOne = Console.ReadLine();
                int numberOne = GetNumber(strNumberOne);
                Console.WriteLine("请输入第二个数字");
                string strNumberTwo = Console.ReadLine();
                int numberTwo = GetNumber(strNumberTwo);

                //判断第一个数字是否小于第二个数字
                JudgeNumber(ref numberOne, ref numberTwo);

                //求和
                int sum = GetSum(numberOne, numberTwo);
                Console.WriteLine(sum);
                Console.ReadKey();


            }


            public static void JudgeNumber(ref int n1, ref int n2)
            {
                while (true)
                {
                    if (n1 < n2)
                    {
                        //复合题意
                        return;
                    }
                    else//>=2
                    {
                        Console.WriteLine("第一个数字不能大于或者等于第二个数字,请重新输入第一个数字");
                        string s1 = Console.ReadLine();
                        //调用GetNumber
                        n1 = GetNumber(s1);
                        Console.WriteLine("请重新输入第二个数字");
                        string s2 = Console.ReadLine();
                        n2 = GetNumber(s2);
                    }

                }

            }
            public static int GetNumber(string s)
            {
                while (true)
                {
                    try
                    {
                        int number = Convert.ToInt32(s);
                        return number;
                    }
                    catch
                    {
                        Console.WriteLine("输入有误!!!请重新输入");
                        s = Console.ReadLine();
                    }
                }
            }

            public static int GetSum(int n1, int n2)
            {
                int sum = 0;
                for (int i = n1; i <= n2; i++)
                {
                    sum += i;
                }
                return sum;
            }
            }
            }
            */
            //====== 方法练习1
            /*
            using System;
            using System.Collections.Generic;
            using System.Linq;
            using System.Text;
            using System.Threading.Tasks;

            namespace _01方法的练习
            {
            class Program
            {
            static void Main(string[] args)
            {
                //79、用方法来实现:有一个字符串数组:
                //{ "马龙", "迈克尔乔丹", "雷吉米勒", "蒂姆邓肯", "科比布莱恩特" },请输出最
                //string[] names = { "马龙", "迈克尔乔丹", "雷吉米勒", "蒂姆邓肯", "科比布莱恩特" };
                //string max = GetLongest(names);
                //Console.WriteLine(max);
                //Console.ReadKey();

                //  80、用方法来实现:请计算出一个整型数组的平均值。保留两位小数
                //int[] numbers = { 1, 2, 7 };
                //double avg = GetAvg(numbers);
                //保留两位小数
                //string s = avg.ToString("0.00");
                //avg = Convert.ToDouble(s);
                //Console.WriteLine(avg);

                //Console.WriteLine(s);
                //Console.WriteLine("{0:0.00}", avg);
                //Console.WriteLine(avg);

                //double d = 3.148;
                //Console.WriteLine(d.ToString("0.00"));

                // Console.WriteLine("{0:0.00}",d);


                //1、写一个方法,用来判断用户输入的数字是不是质数  
                //再写一个方法 要求用户只能输入数字 输入有误就一直让用户输入
                while (true)
                {
                    Console.WriteLine("请输入一个数字,我们将判断你输入的数字是否是质数");
                    string strNumber = Console.ReadLine();

                    int number = GetNumber(strNumber);

                    bool b = IsPrime(number);
                    Console.WriteLine(b);


                    Console.ReadKey();
                }

            }

            public static bool IsPrime(int number)
            {
                if (number < 2)
                {
                    return false;
                }
                else//>=2
                {
                    //让这个数字从2开始除 除到自身的前一位
                    for (int i = 2; i < number; i++)
                    {
                        if (number % i == 0)
                        {
                            //给非质数准备的
                            return false;
                        }
                        //else
                        //{
                        //    return true;
                        //}
                    }
                    //给质数准备的
                    return true;
                }
            }


            public static int GetNumber(string strNumber)
            {
                while (true)
                {
                    try
                    {
                        int number = Convert.ToInt32(strNumber);
                        return number;
                    }
                    catch
                    {
                        Console.WriteLine("请重新输入");
                        strNumber = Console.ReadLine();
                    }
                }
            }
            public static double GetAvg(int[] nums)
            {
                double sum = 0;
                for (int i = 0; i < nums.Length; i++)
                {
                    sum += nums[i];
                }
                return sum / nums.Length;
            }
            /// <summary>
            ///求一个字符串数组中最长的元素
            /// </summary>
            /// <param name="s"></param>
            /// <returns></returns>
            public static string GetLongest(string[] s)
            {
                string max = s[0];
                for (int i = 0; i < s.Length; i++)
                {
                    if (s[i].Length > max.Length)
                    {
                        max = s[i];
                    }
                }
                return max;
            }
            }
            }
            */
            //====== 方法练习2
            /*
            using System;
            using System.Collections.Generic;
            using System.Linq;
            using System.Text;
            using System.Threading.Tasks;

            namespace _02方法的练习
            {
            class Programe
            {
            static void Main(string[] args)
            {
                //95、接受输入后判断其等级并显示出来。
                //判断依据如下:等级={优 (90~100分);良 (80~89分)
                //Console.WriteLine("请输入考试成绩");
                //int score = Convert.ToInt32(Console.ReadLine());

                //string level = GetLevel(score);
                //Console.WriteLine(level);
                //Console.ReadKey();


                //97、请将字符串数组{ "中国", "美国", "巴西", "澳大利亚", "加拿大" }中的内容反转
                //string[] names = { "中国", "美国", "巴西", "澳大利亚", "加拿大" };
                //Test(names);
                //for (int i = 0; i < names.Length; i++)
                //{
                //    Console.WriteLine(names[i]);
                //}
                //Console.ReadKey();

                //98写一个方法 计算圆的面积和周长  面积是 pI*R*R  周长是 2*Pi*r

                double r = 5;
                double perimeter;
                double area;
                GetPerimeterArea(r, out perimeter, out area);
                Console.WriteLine(perimeter);
                Console.WriteLine(area);
                Console.ReadKey();
            }


            public static void GetPerimeterArea(double r, out double perimeter, out double area)
            {
                perimeter = 2 * 3.14 * r;
                area = 3.14 * r * r;
            }


            public static void Test(string[] names)
            {
                for (int i = 0; i < names.Length / 2; i++)
                {
                    string temp = names[i];
                    names[i] = names[names.Length - 1 - i];
                    names[names.Length - 1 - i] = temp;
                }
            }


            public static string GetLevel(int score)
            {
                string level = "";
                switch (score / 10)
                {
                    case 10:
                    case 9: level = "优"; break;
                    case 8: level = "良"; break;
                    case 7: level = "中"; break;
                    case 6: level = "差"; break;
                    default:
                        level = "不及格";
                        break;
                }
                return level;
            }

            }
            }
            */
            //====== 方法练习3
            /*
            using System;
            using System.Collections.Generic;
            using System.Linq;
            using System.Text;
            using System.Threading.Tasks;

            namespace _03方法的练习
            {
            class Program
            {
            static void Main(string[] args)
            {
                //100、计算任意多个数间的最大值(提示:params)。
                //int sum = GetSum(1, 2, 3, 4, 5, 6, 7);
                //Console.WriteLine(sum);
                //Console.ReadKey();

                //101、请通过冒泡排序法对整数数组{ 1, 3, 5, 7, 90, 2, 4, 6, 8, 10 }实现升序排序。
                //int[] nums = { 1, 3, 5, 7, 90, 2, 4, 6, 8, 10 };
                //Change(nums);
                //for (int i = 0; i < nums.Length; i++)
                //{
                //    Console.WriteLine(nums[i]);
                //}
                //Console.ReadKey();

                //102将一个字符串数组输出为|分割的形式,比如“梅西|卡卡|郑大世”(用方法来实现此功能)
                string[] names = { "梅西", "卡卡", "郑大世" };
                string str = ProcessString(names);
                Console.WriteLine(str);
                Console.ReadKey();
                //"梅西|卡卡|郑大世"

            }
            public static string ProcessString(string[] names)
            {
                string str = null;
                for (int i = 0; i < names.Length - 1; i++)
                {
                    str += names[i] + "|";
                }
                return str + names[names.Length - 1];
            }

            public static void Change(int[] nums)
            {
                for (int i = 0; i < nums.Length - 1; i++)
                {
                    for (int j = 0; j < nums.Length - 1 - i; j++)
                    {
                        if (nums[j] > nums[j + 1])
                        {
                            int temp = nums[j];
                            nums[j] = nums[j + 1];
                            nums[j + 1] = temp;
                        }
                    }
                }
            }


            public static int GetSum(params int[] nums)
            {
                int sum = 0;
                for (int i = 0; i < nums.Length; i++)
                {
                    sum += nums[i];
                }
                return sum;
            }
            }
            }
            */
            //====== 项目飞行棋
            /*
            using System;
            using System.Collections.Generic;
            using System.Linq;
            using System.Text;
            using System.Threading.Tasks;

            namespace _04飞行棋游戏
            {
            class Program
            {
            //我们用静态字段来模拟全局变量
            static int[] Maps = new int[100];
            //声明一个静态数组用来存储玩家A跟玩家B的坐标
            static int[] PlayerPos = new int[2];
            //存储两个玩家的姓名
            static string[] PlayerNames = new string[2];
            //两个玩家的标记
            static bool[] Flags = new bool[2];//Flags[0]默认是false  Flags[1]默认也是false
            static void Main(string[] args)
            {
                GameShow();
                #region 输入玩家姓名
                Console.WriteLine("请输入玩家A的姓名");
                PlayerNames[0] = Console.ReadLine();
                while (PlayerNames[0] == "")
                {
                    Console.WriteLine("玩家A的姓名不能为空,请重新输入");
                    PlayerNames[0] = Console.ReadLine();
                }
                Console.WriteLine("请输入玩家B的姓名");
                PlayerNames[1] = Console.ReadLine();
                while (PlayerNames[1] == "" || PlayerNames[1] == PlayerNames[0])
                {
                    if (PlayerNames[1] == "")
                    {
                        Console.WriteLine("玩家B的姓名不能为空,请重新输入");
                        PlayerNames[1] = Console.ReadLine();
                    }
                    else
                    {
                        Console.WriteLine("玩家B的姓名不能玩家A的形同,请重新输入");
                        PlayerNames[1] = Console.ReadLine();
                    }
                }
                #endregion
                //玩家姓名输入OK之后 我们首先应该清屏 
                Console.Clear();//清屏
                GameShow();
                Console.WriteLine("{0}的士兵用A表示", PlayerNames[0]);
                Console.WriteLine("{0}的士兵用B表示", PlayerNames[1]);
                //在画地图之前 首先应该初始化地图
                InitailMap();
                DrawMap();

                //当玩家A跟玩家B没有一个人在终点的时候 两个玩家不停的去玩游戏
                while (PlayerPos[0] < 99 && PlayerPos[1] < 99)
                {
                    if (Flags[0] == false)
                    {
                        PlayGame(0);//Flags[0]=true;
                    }
                    else
                    {
                        Flags[0] = false;
                    }
                    if (PlayerPos[0] >= 99)
                    {
                        Console.WriteLine("玩家{0}无耻的赢了玩家{1}", PlayerNames[0], PlayerNames[1]);
                        break;
                    }
                    if (Flags[1] == false)
                    {
                        PlayGame(1);
                    }
                    else
                    {
                        Flags[1] = false;
                    }
                    if (PlayerPos[1] >= 99)
                    {
                        Console.WriteLine("玩家{0}无耻的赢了玩家{1}", PlayerNames[1], PlayerNames[0]);
                        break;
                    }
                }//while



                Win();

                Console.ReadKey();
            }



            /// <summary>
            /// 胜利
            /// </summary>
            public static void Win()
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine("                                          ◆                      ");
                Console.WriteLine("                    ■                  ◆               ■        ■");
                Console.WriteLine("      ■■■■  ■  ■                ◆■         ■    ■        ■");
                Console.WriteLine("      ■    ■  ■  ■              ◆  ■         ■    ■        ■");
                Console.WriteLine("      ■    ■ ■■■■■■       ■■■■■■■   ■    ■        ■");
                Console.WriteLine("      ■■■■ ■   ■                ●■●       ■    ■        ■");
                Console.WriteLine("      ■    ■      ■               ● ■ ●      ■    ■        ■");
                Console.WriteLine("      ■    ■ ■■■■■■         ●  ■  ●     ■    ■        ■");
                Console.WriteLine("      ■■■■      ■             ●   ■   ■    ■    ■        ■");
                Console.WriteLine("      ■    ■      ■            ■    ■         ■    ■        ■");
                Console.WriteLine("      ■    ■      ■                  ■               ■        ■ ");
                Console.WriteLine("     ■     ■      ■                  ■           ●  ■          ");
                Console.WriteLine("    ■    ■■ ■■■■■■             ■              ●         ●");
                Console.ResetColor();
            }
            /// <summary>
            /// 画游戏头
            /// </summary>
            public static void GameShow()
            {
                Console.ForegroundColor = ConsoleColor.Yellow;
                Console.WriteLine("**************************");
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine("**************************");
                Console.ForegroundColor = ConsoleColor.Green;
                Console.WriteLine("**************************");
                Console.ForegroundColor = ConsoleColor.Blue;
                Console.WriteLine("***0505.Net基础班飞行棋***");
                Console.ForegroundColor = ConsoleColor.Cyan;
                Console.WriteLine("**************************");
                Console.ForegroundColor = ConsoleColor.Green;
                Console.WriteLine("**************************");
            }
            /// <summary>
            /// 初始化地图
            /// </summary>
            public static void InitailMap()
            {
                int[] luckyturn = { 6, 23, 40, 55, 69, 83 };//幸运轮盘◎
                for (int i = 0; i < luckyturn.Length; i++)
                {
                    //int index = luckyturn[i];
                    Maps[luckyturn[i]] = 1;
                }
                int[] landMine = { 5, 13, 17, 33, 38, 50, 64, 80, 94 };//地雷☆
                for (int i = 0; i < landMine.Length; i++)
                {
                    Maps[landMine[i]] = 2;
                }
                int[] pause = { 9, 27, 60, 93, 2, 3, 4, 7, 8 };//暂停▲
                for (int i = 0; i < pause.Length; i++)
                {
                    Maps[pause[i]] = 3;
                }
                int[] timeTunnel = { 20, 25, 45, 63, 72, 88, 90 };//时空隧道卐
                for (int i = 0; i < timeTunnel.Length; i++)
                {
                    Maps[timeTunnel[i]] = 4;
                }
            }
            public static void DrawMap()
            {
                Console.WriteLine("图例:幸运轮盘:◎   地雷:☆   暂停:▲   时空隧道:卐");
                #region  第一横行
                for (int i = 0; i < 30; i++)
                {
                    Console.Write(DrawStringMap(i));
                }//for
                #endregion
                //画完第一横行后 应该换行
                Console.WriteLine();
                #region 第一竖行
                for (int i = 30; i < 35; i++)
                {
                    for (int j = 0; j <= 28; j++)
                    {
                        Console.Write("  ");
                    }
                    Console.Write(DrawStringMap(i));

                    Console.WriteLine();
                }
                #endregion
                #region 第二横行
                for (int i = 64; i >= 35; i--)
                {
                    Console.Write(DrawStringMap(i));
                }
                #endregion
                //画完第二横行 应该换行
                Console.WriteLine();
                #region 第二竖行
                for (int i = 65; i <= 69; i++)
                {
                    Console.WriteLine(DrawStringMap(i));
                }
                #endregion
                #region 第三横行
                for (int i = 70; i <= 99; i++)
                {
                    Console.Write(DrawStringMap(i));
                }
                #endregion

                //画完最后一行  应该换行
                Console.WriteLine();
            }//DrawMap方法的结尾
            /// <summary>
            /// 从画地图的方法中抽象出来的一个方法
            /// </summary>
            /// <param name="i"></param>
            /// <returns></returns>
            public static string DrawStringMap(int i)
            {
                string str = "";
                #region 画图
                //如果玩家A跟玩家B的坐标相同,并且都在这个地图上,画一个尖括号
                if (PlayerPos[0] == PlayerPos[1] && PlayerPos[0] == i)
                {
                    str = "<>";
                }
                else if (PlayerPos[0] == i)
                {
                    //shift+空格
                    str = "A";
                }
                else if (PlayerPos[1] == i)
                {
                    str = "B";
                }
                else
                {
                    switch (Maps[i])
                    {
                        case 0:
                            Console.ForegroundColor = ConsoleColor.Yellow;
                            str = "□";
                            break;
                        case 1:
                            Console.ForegroundColor = ConsoleColor.Green;
                            str = "◎";
                            break;
                        case 2:
                            Console.ForegroundColor = ConsoleColor.Red;
                            str = "☆";
                            break;
                        case 3:
                            Console.ForegroundColor = ConsoleColor.Blue;
                            str = "▲";
                            break;
                        case 4:
                            Console.ForegroundColor = ConsoleColor.DarkCyan;
                            str = "卐";
                            break;
                    }//switch
                }//else
                return str;
                #endregion
            }
            /// <summary>
            /// 玩游戏
            /// </summary>
            public static void PlayGame(int playerNumber)
            {
                Random r = new Random();
                int rNumber = r.Next(1, 7);
                Console.WriteLine("{0}按任意键开始掷骰子", PlayerNames[playerNumber]);
                Console.ReadKey(true);
                Console.WriteLine("{0}掷出了{1}", PlayerNames[playerNumber], rNumber);
                PlayerPos[playerNumber] += rNumber;
                ChangePos();
                Console.ReadKey(true);
                Console.WriteLine("{0}按任意键开始行动", PlayerNames[playerNumber]);
                Console.ReadKey(true);
                Console.WriteLine("{0}行动完了", PlayerNames[playerNumber]);
                Console.ReadKey(true);
                //玩家A有可能踩到了玩家B 方块 幸运轮盘 地雷 暂停 时空隧道
                if (PlayerPos[playerNumber] == PlayerPos[1 - playerNumber])
                {
                    Console.WriteLine("玩家{0}踩到了玩家{1},玩家{2}退6格", PlayerNames[playerNumber], PlayerNames[1 - playerNumber], PlayerNames[1 - playerNumber]);
                    PlayerPos[1 - playerNumber] -= 6;
                    ChangePos();
                    Console.ReadKey(true);
                }
                else//踩到了关卡
                {
                    //玩家的坐标
                    switch (Maps[PlayerPos[playerNumber]])// 0 1 2 3 4
                    {
                        case 0:
                            Console.WriteLine("玩家{0}踩到了方块,安全。", PlayerNames[playerNumber]);
                            Console.ReadKey(true);
                            break;
                        case 1:
                            Console.WriteLine("玩家{0}踩到了幸运轮盘,请选择 1--交换位置 2--轰炸对方", PlayerNames[playerNumber]);
                            string input = Console.ReadLine();
                            while (true)
                            {
                                if (input == "1")
                                {
                                    Console.WriteLine("玩家{0}选择跟玩家{1}交换位置", PlayerNames[playerNumber], PlayerNames[1 - playerNumber]);
                                    Console.ReadKey(true);
                                    int temp = PlayerPos[playerNumber];
                                    PlayerPos[playerNumber] = PlayerPos[1 - playerNumber];
                                    PlayerPos[1 - playerNumber] = temp;
                                    Console.WriteLine("交换完成!!!按任意键继续游戏!!!");
                                    Console.ReadKey(true);
                                    break;
                                }
                                else if (input == "2")
                                {
                                    Console.WriteLine("玩家{0}选择轰炸玩家{1},玩家{2}退6格", PlayerNames[playerNumber], PlayerNames[1 - playerNumber], PlayerNames[1 - playerNumber]);
                                    Console.ReadKey(true);
                                    PlayerPos[1 - playerNumber] -= 6;
                                    ChangePos();
                                    Console.WriteLine("玩家{0}退了6格", PlayerNames[1 - playerNumber]);
                                    Console.ReadKey(true);
                                    break;
                                }
                                else
                                {
                                    Console.WriteLine("只能输入1或者2  1--交换位置 2--轰炸对方");
                                    input = Console.ReadLine();
                                }
                            }
                            break;
                        case 2:
                            Console.WriteLine("玩家{0}踩到了地雷,退6格", PlayerNames[playerNumber]);
                            Console.ReadKey(true);
                            PlayerPos[playerNumber] -= 6;
                            ChangePos();
                            break;
                        case 3:
                            Console.WriteLine("玩家{0}踩到了暂停,暂停一回合", PlayerNames[playerNumber]);
                            Flags[playerNumber] = true;
                            Console.ReadKey(true);
                            break;
                        case 4:
                            Console.WriteLine("玩家{0}踩到了时空隧道,前进10格", PlayerNames[playerNumber]);
                            PlayerPos[playerNumber] += 10;
                            ChangePos();
                            Console.ReadKey(true);
                            break;
                    }//switch
                }//else
                ChangePos();//perfect
                Console.Clear();
                DrawMap();
            }
            /// <summary>
            /// 当玩家坐标发生改变的时候调用
            /// </summary>
            public static void ChangePos()
            {
                if (PlayerPos[0] < 0)
                {
                    PlayerPos[0] = 0;
                }
                if (PlayerPos[0] >= 99)
                {
                    PlayerPos[0] = 99;
                }

                if (PlayerPos[1] < 0)
                {
                    PlayerPos[1] = 0;
                }
                if (PlayerPos[1] >= 99)
                {
                    PlayerPos[1] = 99;
                }
            }







            }
            }
            */
            //====== 01面向对象
            /*          
                      using System;
                      using System.Collections.Generic;
                      using System.Linq;
                      using System.Text;
                      using System.Threading.Tasks;

            namespace _01面向对象
              {
                  class Program
                  {
                      static void Main(string[] args)
                      {
                          // string s;
                          //  Person sunQuan;//自定义类
                          // 创建Person类的对象
                          Person suQuan = new Person();
                          suQuan.Name = "孙全";
                          suQuan.Age = -23;
                          suQuan.Gender = '春';
                          suQuan.CHLSS();
                          Console.ReadKey();
                      }
                  }
              }

                      using System;
            using System.Collections.Generic;
            using System.Linq;
            using System.Text;
            using System.Threading.Tasks;

            namespace _01面向对象
            {
              public class Person
              {
                  private string _name;
                  public string Name
                  {
                      //当你输出属性的值得时候 会执行get方法
                      get { return _name; }
                      //当你给属性赋值的时候 首先会执行set方法
                      set { _name = value; }
                  }
                  private int _age;
                  public int Age
                  {
                      get { return _age; }
                      set
                      {

                          if (value < 0 || value > 100)
                          {
                              value = 0;
                          }

                          _age = value;
                      }
                  }
                  private char _gender;
                  public char Gender
                  {
                      get
                      {
                          if (_gender != '男' && _gender != '女')
                          {
                              return _gender = '男';
                          }
                          return _gender;

                      }
                      set { _gender = value; }
                  }
                  public void CHLSS()
                  {
                      Console.WriteLine("我叫{0},我今年{1}岁了,我是{2}生,我可以吃喝拉撒睡哟~~~", this.Name, this.Age, this.Gender);
                  }
              }
              }


              */
            //====== 面向对象2复习
            /*
                        using System;
                        using System.Collections.Generic;
                        using System.Linq;
                        using System.Text;
                        using System.Threading.Tasks;

            namespace _02面向对象复习
                {
                    class Program
                    {
                        static void Main(string[] args)
                        {
                            Person p = new Person();
                            p.Age = -110;
                            p.Name = "zhangsan";
                            p.Gender = '中';
                            p.SayHello();

                            Person p2 = new Person();
                            p2.Name = "李四";
                            p2.Age = 88;
                            p2.Gender = '女';
                            p2.SayHello();
                            Console.ReadKey();
                        }
                    }
                }

                using System;
            using System.Collections.Generic;
            using System.Linq;
            using System.Text;
            using System.Threading.Tasks;

            namespace _02面向对象复习
                {
                    public class Person
                    {
                        //字段、属性、方法
                        string _name;
                        public string Name
                        {
                            get
                            {
                                if (_name != "孙全")
                                {
                                    return _name = "孙全";
                                }
                                return _name;
                            }
                            set { _name = value; }
                        }
                        int _age;
                        public int Age
                        {
                            get { return _age; }
                            set
                            {

                                if (value < 0 || value > 100)
                                {
                                    value = 0;
                                }
                                _age = value;
                            }
                        }
                        char _gender;
                        public char Gender
                        {
                            get
                            {
                                if (_gender != '男' && _gender != '女')
                                {
                                    return _gender = '男';
                                }

                                return _gender;
                            }
                            set { _gender = value; }
                        }


                        public void SayHello()
                        {
                            Console.WriteLine("我叫{0},我今年{1}岁了,我是{2}生", this.Name, this.Age, this.Gender);
                        }



                    }
                }
            */
            //====== 静态和非静态的区别
            /*
            using System;
            using System.Collections.Generic;
            using System.Linq;
            using System.Text;
            using System.Threading.Tasks;

            namespace _03静态和非静态的区别
            {
            public class Person
            {
            private static string _name;

            public static string Name
            {
                get { return Person._name; }
                set { Person._name = value; }
            }
            private char _gender;

            public char Gender
            {
                get { return _gender; }
                set { _gender = value; }
            }
            public void M1()
            {

                Console.WriteLine("我是非静态的方法");
            }
            public static void M2()
            {

                Console.WriteLine("我是一个静态方法");
            }
            }
            }

            using System;
            using System.Collections.Generic;
            using System.Linq;
            using System.Text;
            using System.Threading.Tasks;

            namespace _03静态和非静态的区别
            {
            public static class Student
            {
            private static string _name;

            public static string Name
            {
                get { return Student._name; }
                set { Student._name = value; }
            }

            public static void M1()
            {
                Console.WriteLine("Hello World");
            }


            // private int _age;


            }
            }

            using System;
            using System.Collections.Generic;
            using System.Linq;
            using System.Text;
            using System.Threading.Tasks;

            namespace _03静态和非静态的区别
            {
            class Program
            {
            static void Main(string[] args)
            {
                //调用实例成员
                Person p = new Person();
                p.M1();//实例方法
                Person.M2();//静态方法
                            // Student s = new Student();


                Console.WriteLine();
                Console.ReadKey();
            }
            }
            }
            */
            //====== 04面向对象练习
            /*
            using System;
            using System.Collections.Generic;
            using System.Linq;
            using System.Text;
            using System.Threading.Tasks;

            namespace _04面向对象练习
            {
            public class Student
            {
            //字段、属性、方法、构造函数

            //析构函数  构造函数



            //当程序结束的时候  析构函数才执行
            //帮助我们释放资源
            //GC Garbage Collection
            ~Student()
            {
                Console.WriteLine("我是析构函数");
            }


            public Student(string name, int age, char gender, int chinese, int math, int english)
            {
                this.Name = name;
                this.Age = age;
                this.Gender = gender;
                this.Chinese = chinese;
                this.Math = math;
                this.English = english;
            }
            public Student(string name, int chinese, int math, int english) : this(name, 0, 'c', chinese, math, english)
            {
                //this.Name = name;
                //this.Chinese = chinese;
                //this.Math = math;
                //this.English = english;
            }
            public Student(string name, int age, char gender)
            {
                this.Name = name;
                if (age < 0 || age > 100)
                {
                    age = 0;
                }
                this.Age = age;
                this.Gender = gender;
            }

            public Student()
            {

            }



            private string _name;
            public string Name
            {
                get { return _name; }
                set { _name = value; }
            }
            private int _age;
            public int Age
            {
                get { return _age; }
                set
                {
                    if (value < 0 || value > 100)
                    {
                        value = 0;
                    }
                    _age = value;
                }
            }
            private char _gender;
            public char Gender
            {
                get
                {
                    if (_gender != '男' && _gender != '女')
                    {
                        return _gender = '男';
                    }
                    return _gender;
                }
                set { _gender = value; }
            }
            private int _chinese;
            public int Chinese
            {
                get { return _chinese; }
                set { _chinese = value; }
            }
            private int _math;
            public int Math
            {
                get { return _math; }
                set { _math = value; }
            }
            private int _english;
            public int English
            {
                get { return _english; }
                set { _english = value; }
            }


            public void SayHello()
            {
                Console.WriteLine("我叫{0},我几年{1}岁了,我是{2}生", this.Name, this.Age, this.Gender);
            }

            public void ShowScore()
            {
                Console.WriteLine("我叫{0},我的总成绩是{1},平均成绩是{2}", this.Name, this.Chinese + this.Math + this.English, (this.Chinese + this.Math + this.English) / 3);
            }

            }
            }

            using System;
            using System.Collections.Generic;
            using System.Linq;
            using System.Text;
            using System.Threading.Tasks;

            namespace _04面向对象练习
            {
            class Program
            {
            static void Main(string[] args)
            {

                Student s = new Student("张三", 100, 100, 100);
                Console.ReadKey();
                //Student zsStudent = new Student("张三", 18, '男', 100, 100, 100);

                //zsStudent.SayHello();
                //zsStudent.ShowScore();


                //Student xlStudent = new Student("小兰", 16, '女', 50, 50, 50);

                //xlStudent.SayHello();
                //xlStudent.ShowScore();
                //Console.ReadKey();



            }
            }
            }
            */
            //====== 05练习
            /*
            using System;
            using System.Collections.Generic;
            using System.Linq;
            using System.Text;
            using System.Threading.Tasks;

            namespace _05练习
            {
            public class Ticket
            {
            //写一个Ticket类,有一个距离属性(本属性只读,在构造方法中赋值),
            //不能为负数,有一个价格属性,价格属性只读,
            //并且根据距离distance计算价格Price (1元/公里):
            //        0-100公里        票价不打折
            //101-200公里    总额打9.5折
            //201-300公里    总额打9折
            //300公里以上    总额打8折

            private double _distance;
            public double Distance
            {
                get { return _distance; }
            }

            public Ticket(double distance)
            {
                if (distance < 0)
                {
                    distance = 0;
                }
                this._distance = distance;
            }

            private double _price;
            //        0-100公里        票价不打折
            //101-200公里    总额打9.5折
            //201-300公里    总额打9折
            //300公里以上    总额打8折
            public double Price
            {
                get
                {
                    if (_distance > 0 && _distance <= 100)
                    {
                        return _distance * 1.0;
                    }
                    else if (_distance >= 101 && _distance < 200)
                    {
                        return _distance * 0.95;
                    }
                    else if (_distance >= 201 && _distance < 300)
                    {
                        return _distance * 0.9;
                    }
                    else
                    {
                        return _distance * 0.8;
                    }
                }
            }


            public void ShowTicket()
            {
                Console.WriteLine("{0}公里需要{1}元", Distance, Price);
            }

            }
            }

            using System;
            using System.Collections.Generic;
            using System.Linq;
            using System.Text;
            using System.Threading.Tasks;

            namespace _05练习
            {
            class Program
            {
            static void Main(string[] args)
            {
                Ticket t = new Ticket(150);
                t.ShowTicket();
                Console.ReadKey();
            }
            }
            }
            */
            //====== 02、命名空间
            /*
            using System;
            using System.Linq;
            using System.Text;
            using System.Collections.Generic;
            using System.Threading.Tasks;
            using System.IO;
            using _01复习;
            namespace _02_命名空间
            {
            class Program
            {
            static void Main(string[] args)
            {
                Person zsPerson = new Person();
                zsPerson.Name = "张三";
                Console.WriteLine(zsPerson.Name);
                Console.ReadKey();

                //A--->ProjectA---顾客类
                //B--->ProjcetB---顾客类
                //C-->ProjectC---顾客类
            }
            }
            }
            */

            //====== 值类型和引用类型
            /*
            using System;
            using System.Collections.Generic;
            using System.Linq;
            using System.Text;
            using System.Threading.Tasks;

            namespace _03值类型和引用类型
            {
            class Program
            {
            static void Main(string[] args)
            {

            }
            }
            }
            */

            //====== 字符串
            /*

            using System;
            using System.Collections.Generic;
            using System.Linq;
            using System.Text;
            using System.Threading.Tasks;

            namespace _04字符串
            {
            class Program
            {
            static void Main(string[] args)
            {
                //字符串的不可变性
                //string name = "张三";
                //name = "孙全";
                //Console.WriteLine(name);
                //Console.ReadKey();

                //string s1 = "张三";
                //string s2 = "张三";
                //Console.ReadKey();

                //可以讲string类型 看做是char类型的一个只读数组
                string s = "abcdefg";
                s = "bbcdefg";
                // s[0] = 'b';不能这样做  因为是只读的
                //首先将字符串转换为char类型的数组
                char[] chs = s.ToCharArray();
                chs[0] = 'b';
                //将字符数组转换为我们的字符串
                s = new string(chs);
                //既然可以将string看做char类型的只读数组,所以我可以通过下标去访问字符串中的某一个元素
                Console.WriteLine(s[0]);
                Console.WriteLine(s);
                Console.ReadKey();
            }
            }
            }
            */

            //====== StringBuilder
            /*
            using System;
            using System.Collections.Generic;
            using System.Diagnostics;
            using System.Linq;
            using System.Text;
            using System.Threading.Tasks;

            namespace _05StringBuilder
            {
            class Program
            {
            static void Main(string[] args)
            {
                StringBuilder sb = new StringBuilder();
                string str = null;
                //创建了一个计时器,用来记录程序运行的时间
                //00:00:00.0422166
                Stopwatch sw = new Stopwatch();
                sw.Start();//开始计时
                for (int i = 0; i < 100000; i++)
                {
                    //str += i;
                    sb.Append(i);
                }
                sw.Stop();//结束计时
                Console.WriteLine(sb.ToString());
                Console.WriteLine(sw.Elapsed);
                Console.ReadKey();




            }
            }
            }

            */

            //====== 字符串的各种方法
            /*
            using System;
            using System.Collections.Generic;
            using System.Linq;
            using System.Text;
            using System.Threading.Tasks;

            namespace _06字符串的各种方法
            {
            class Program
            {
            static void Main(string[] args)
            {
                //练习一:随机输入你心中想到的一个名字,然后输出它的字符串长度  Length:可以得字符串的长度
                //Console.WriteLine("请输入你心中想的那个人的名字");
                //string name = Console.ReadLine();
                //Console.WriteLine("你心中想的人的名字的长度是{0}",name.Length);
                //Console.ReadKey();


                //Console.WriteLine("请输入你喜欢的课程");
                //string lessonOne = Console.ReadLine();
                ////将字符串转换成大写
                ////  lessonOne = lessonOne.ToUpper();
                ////将字符串转换成小写形式
                //// lessonOne = lessonOne.ToLower();
                //Console.WriteLine("请输入你喜欢的课程");
                //string lessonTwo = Console.ReadLine();
                ////   lessonTwo = lessonTwo.ToUpper();
                ////   lessonTwo = lessonTwo.ToLower();
                //if (lessonOne.Equals(lessonTwo,StringComparison.OrdinalIgnoreCase))
                //{
                //    Console.WriteLine("你们俩喜欢的课程相同");
                //}
                //else
                //{
                //    Console.WriteLine("你们俩喜欢的课程不同");
                //}
                //Console.ReadKey();


                //string s = "a b   dfd _   +    =  ,,, fdf ";
                ////分割字符串Split
                //char[] chs = { ' ', '_', '+', '=', ',' };
                //string[] str = s.Split(chs,StringSplitOptions.RemoveEmptyEntries);
                //Console.ReadKey();


                //练习:从日期字符串("2008-08-08")中分析出年、月、日;2008年08月08日。
                //让用户输入一个日期格式如:2008-01-02,你输出你输入的日期为2008年1月2日

                //string s = "2008-08-08";
                ////  char[] chs = { '-' };
                //string[] date = s.Split(new char[] { '-' }, StringSplitOptions.RemoveEmptyEntries);
                //Console.WriteLine("{0}年{1}月{2}日", date[0], date[1], date[2]);
                //Console.ReadKey();
                //老赵

                //string str = "国家关键人物老赵";
                //if (str.Contains("老赵"))
                //{
                //    str = str.Replace("老赵", "**");
                //}
                //Console.WriteLine(str);
                //Console.ReadKey();


                //Substring 截取字符串

                //string str = "今天天气好晴朗,处处好风光";
                //str = str.Substring(1,2);
                //Console.WriteLine(str);
                //Console.ReadKey();

                //string str = "今天天气好晴朗,处处好风光";
                //if (str.EndsWith("风"))
                //{
                //    Console.WriteLine("是的");
                //}
                //else
                //{
                //    Console.WriteLine("不是的");
                //}
                //Console.ReadKey();


                //string str = "今天天天气好晴朗,天天处天好风光";
                //int index = str.IndexOf('哈',2);
                //Console.WriteLine(index);
                //Console.ReadKey();


                //string str = "今天天气好晴朗,处处好风光";
                //int index = str.LastIndexOf('天');
                //Console.WriteLine(index);
                //Console.ReadKey();


                ////LastIndexOf  Substring
                //string path = @"c:\a\b\c苍\d\e苍\f\g\\fd\fd\fdf\d\vfd\苍老师苍.wav";
                //int index = path.LastIndexOf("\\");
                //path = path.Substring(index+1);
                //Console.WriteLine(path);
                //Console.ReadKey();



                // string str = "            hahahah          ";
                //// str = str.Trim();
                // //str = str.TrimStart();
                // str = str.TrimEnd();
                // Console.Write(str);
                // Console.ReadKey();

                //string str = "fdsfdsfds";
                //if (string.IsNullOrEmpty(str))
                //{
                //    Console.WriteLine("是的");
                //}
                //else
                //{
                //    Console.WriteLine("不是");
                //}
                //string[] names = { "张三", "李四", "王五", "赵六", "田七" };
                ////张三|李四|王五|赵六|田七
                //string strNew = string.Join("|", "张三","李四","王五","赵六","田七");
                //Console.WriteLine(strNew);
                //Console.ReadKey();




            }
            }
            }

                       */

            //====== 字符串的练习
            /*
            using System;
            using System.Collections.Generic;
            using System.IO;
            using System.Linq;
            using System.Text;
            using System.Threading.Tasks;

namespace _07字符串的练习
    {
        class Program
        {
            static void Main(string[] args)
            {
                //课上练习1:接收用户输入的字符串,将其中的字符以与输入相反的顺序输出。"abc"→"cba"

                //string str = "abcdefg";//ggedcba
                //char[] chs = str.ToCharArray();
                //for (int i = 0; i < chs.Length / 2; i++)
                //{
                //    char temp = chs[i];
                //    chs[i] = chs[chs.Length - 1 - i];
                //    chs[chs.Length - 1 - i] = temp;
                //}

                //str = new string(chs);
                //Console.WriteLine(str);
                //Console.ReadKey();


                //倒叙循环
                //for (int i = str.Length - 1; i >= 0; i--)
                //{
                //    Console.Write(str[i]);
                //}

                //"hello c sharp"→"sharp c hello"
                //string str = "hello c sharp";
                //string[] strNew = str.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                //for (int i = 0; i < strNew.Length / 2; i++)
                //{
                //    string temp = strNew[i];
                //    strNew[i] = strNew[strNew.Length - 1 - i];
                //    strNew[strNew.Length - 1 - i] = temp;
                //}

                //str = string.Join(" ", strNew);
                //Console.WriteLine(str);
                //string.join:将字符串按照指定的分隔符连接
                //Console.WriteLine(strNew);//sharp c hello
                // sharp c hello

                //for (int i = 0; i < strNew.Length; i++)
                //{
                //    Console.WriteLine(strNew[i]);
                //}


                //课上练习3:从Email中提取出用户名和域名:abc@163.com。
                //string email = "285014478@qq.com";
                //int index = email.IndexOf('@');
                //string userName = email.Substring(0, index);
                //string yuMing = email.Substring(index+1);
                //Console.WriteLine(yuMing);
                //Console.WriteLine(userName);


                //Console.ReadKey();


                //课上练习4:文本文件中存储了多个文章标题、作者,
                //标题和作者之间用若干空格(数量不定)隔开,每行一个,
                //标题有的长有的短,输出到控制台的时候最多标题长度10,
                //如果超过10,则截取长度8的子串并且最后添加“...”,加一个竖线后输出作者的名字。


                //string path = @"C:\Users\SpringRain\Desktop\1.txt";
                //string[] contents = File.ReadAllLines(path, Encoding.Default);
                //for (int i = 0; i < contents.Length; i++)
                //{
                //    string[] strNew = contents[i].Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                //    Console.WriteLine((strNew[0].Length>10?strNew[0].Substring(0,8)+"......":strNew[0])+"|"+strNew[1]);
                //}
                //Console.ReadKey();




                //历史就是这么回事儿|袁腾飞
                //c#基础之循环结构while、do-while|老赵
                //AV|苍老师
                //坏蛋是怎样炼成的怎样炼成的|六道


                //让用户输入一句话,找出所有e的位置
                //string str = "咳嗽、咳嗽 哈哈咳嗽 咳 咳  咳嗽";
                //for (int i = 0; i < str.Length; i++)
                //{
                //    if (str[i] == 'e')
                //    {
                //        Console.WriteLine(i);
                //    }
                //}
                //Console.ReadKey();


                //int index = str.IndexOf('e');
                //Console.WriteLine("第1次出现e的位置是{0}", index);
                ////循环体:从上一次出现e的位置加1的位置找下一次e出现的位置
                ////循环条件:index!=-1
                //int count = 1;//用来记录e出现的次数
                //while (index != -1)
                //{
                //    count++;
                //    index = str.IndexOf('e', index + 1);
                //    if (index == -1)
                //    {
                //        break;
                //    }
                //    Console.WriteLine("第{0}次出现e的位置是{1}",count,index);
                //}
                //Console.ReadKey();



                //用户输入一句话,判断这句话中有没有邪恶,如果有邪恶就替换成这种形式然后输出,如:老牛很邪恶,输出后变成老牛很**;
                //string str = "老牛很邪恶";
                //if (str.Contains("邪恶"))
                //{
                //    str = str.Replace("邪恶", "**");
                //}
                //Console.WriteLine(str);
                //Console.ReadKey();

                //把{“诸葛亮”,”鸟叔”,”卡卡西”,”卡哇伊”}变成诸葛亮|鸟叔|卡卡西|卡哇伊,然后再把|切割掉
                string[] names = { "诸葛亮", "鸟叔", "卡卡西", "卡哇伊" };
                string str = string.Join("|", names);
                string[] strNew = str.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries);
                //  Console.WriteLine(str);
                Console.ReadKey();
            }
        }
    }
*/

            //====== 继承
            /*
            using System;
            using System.Collections.Generic;
            using System.Linq;
            using System.Text;
            using System.Threading.Tasks;

namespace _08继承
    {
        class Program
        {
            static void Main(string[] args)
            {
                //Student s = new Student();

                //Driver d = new Driver();
                Student s = new Student("学生", 18, '男', 101);
            }
        }

        public class Person
        {
            private string _name;

            public string Name
            {
                get { return _name; }
                set { _name = value; }
            }

            private int _age;

            public int Age
            {
                get { return _age; }
                set { _age = value; }
            }

            private char _gender;

            public char Gender
            {
                get { return _gender; }
                set { _gender = value; }
            }

            public void CHLSS()
            {
                Console.WriteLine("吃喝拉撒睡");
            }



            public Person(string name, int age, char gender)
            {
                this.Name = name;
                this.Age = age;
                this.Gender = gender;
            }

            //public Person()
            //{

            //}


        }
        public class Student : Person
        {

            public Student(string name, int age, char gender, int id)
                : base(name, age, gender)
            {
                //this.Name = name;
                //this.Age = age;
                //this.Gender = gender;
                this.Id = id;
            }


            private int _id;

            public int Id
            {
                get { return _id; }
                set { _id = value; }
            }



            public void Study()
            {
                Console.WriteLine("学生会学习");
            }
        }
        public class Teacher : Person
        {

            public Teacher(string name, int age, char gender, double salary)
                : base(name, age, gender)
            {
                this.Salary = salary;
            }

            private double _salary;
            public double Salary
            {
                get { return _salary; }
                set { _salary = value; }
            }
            public void Teach()
            {
                Console.WriteLine("老师会讲课");
            }
        }
        public class Driver : Person
        {

            public Driver(string name, int age, char gender, int driveTime)
                : base(name, age, gender)
            {
                this.DirveTime = driveTime;
            }


            private int _dirveTime;
            public int DirveTime
            {
                get { return _dirveTime; }
                set { _dirveTime = value; }
            }
            public void Drive()
            {
                Console.WriteLine("司机会开车");
            }
        }



    }
*/
            //====== 继承练习
            /*
            using System;
            using System.Collections.Generic;
            using System.Linq;
            using System.Text;
            using System.Threading.Tasks;

namespace _09继承练习
    {
        class Program
        {
            static void Main(string[] args)
            {
                //记者:我是记者  我的爱好是偷拍 我的年龄是34 我是一个男狗仔
                //司机:我叫舒马赫 我的年龄是43 我是男人  我的驾龄是 23年
                //程序员:我叫孙全 我的年龄是23 我是男生 我的工作年限是 3年

                Reporter rep = new Reporter("狗仔", 34, '男', "偷拍");

                rep.ReporterSayHello();


                Programmer pro = new Programmer("程序猿", 23, '男', 3);
                pro.ProgrammerSayHello();

                Console.ReadKey();



            }
        }

        public class Person
        {
            private string _name;
            public string Name
            {
                get { return _name; }
                set { _name = value; }
            }
            private int _age;
            public int Age
            {
                get { return _age; }
                set { _age = value; }
            }
            private char _gender;
            public char Gender
            {
                get { return _gender; }
                set { _gender = value; }
            }


            public Person(string name, int age, char gender)
            {
                this.Name = name;
                this.Age = age;
                this.Gender = gender;
            }
        }


        public class Reporter : Person
        {
            public Reporter(string name, int age, char gender, string hobby)
                : base(name, age, gender)
            {
                this.Hobby = hobby;
            }


            private string _hobby;

            public string Hobby
            {
                get { return _hobby; }
                set { _hobby = value; }
            }

            public void ReporterSayHello()
            {
                Console.WriteLine("我叫{0},我是一名狗仔,我的爱好是{1},我是{2}生,我今年{3}岁了", this.Name, this.Hobby, this.Gender, this.Age);
            }
        }


        public class Programmer : Person
        {
            private int _workYear;

            public int WorkYear
            {
                get { return _workYear; }
                set { _workYear = value; }
            }

            public void ProgrammerSayHello()
            {
                Console.WriteLine("我叫{0},我是一名程序猿,我是{1}生,我今年{2}岁了,我的工作年限是{3}年", this.Name, this.Gender, this.Age, this.WorkYear);
            }


            public Programmer(string name, int age, char gender, int workYear)
                : base(name, age, gender)
            {
                this.WorkYear = workYear;
            }
        }

    }
*/
            //====== 关键字
            /*
            using System;
            using System.Collections.Generic;
            using System.Linq;
            using System.Text;
            using System.Threading.Tasks;

namespace _10关键字_new
    {
        class Program
        {
            static void Main(string[] args)
            {
                Reporter rep = new Reporter("记者", 11, '男', "偷拍");
                rep.SayHello();
                rep.Test();
                Console.ReadKey();
            }
        }

        public class Person
        {
            private string _name;
            public string Name
            {
                get { return _name; }
                set { _name = value; }
            }
            private int _age;
            public int Age
            {
                get { return _age; }
                set { _age = value; }
            }
            private char _gender;
            public char Gender
            {
                get { return _gender; }
                set { _gender = value; }
            }


            public Person(string name, int age, char gender)
            {
                this.Name = name;
                this.Age = age;
                this.Gender = gender;
            }

            public void Test()
            {
                Console.WriteLine("测试");
            }

            public void SayHello()
            {
                Console.WriteLine("大家好,我是人类");
            }
        }


        public class Reporter : Person
        {
            public Reporter(string name, int age, char gender, string hobby)
                : base(name, age, gender)
            {
                this.Hobby = hobby;
            }


            private string _hobby;

            public string Hobby
            {
                get { return _hobby; }
                set { _hobby = value; }
            }

            public void ReporterSayHello()
            {
                Console.WriteLine("我叫{0},我是一名狗仔,我的爱好是{1},我是{2}生,我今年{3}岁了", this.Name, this.Hobby, this.Gender, this.Age);
            }


            public new void SayHello()
            {
                Console.WriteLine("大家好,我是记者");
            }
        }


        public class Programmer : Person
        {
            private int _workYear;

            public int WorkYear
            {
                get { return _workYear; }
                set { _workYear = value; }
            }

            public void ProgrammerSayHello()
            {
                Console.WriteLine("我叫{0},我是一名程序猿,我是{1}生,我今年{2}岁了,我的工作年限是{3}年", this.Name, this.Gender, this.Age, this.WorkYear);
            }


            public Programmer(string name, int age, char gender, int workYear)
                : base(name, age, gender)
            {
                this.WorkYear = workYear;
            }


            public new void SayHello()
            {
                Console.WriteLine("大家好,我是程序员");
            }
        }
    }
*/
            //====== 复习
            /*
            using System;
            using System.Collections.Generic;
            using System.Linq;
            using System.Text;
            using System.Threading.Tasks;

namespace _01复习
    {
        class Program
        {
            static void Main(string[] args)
            {
                /*
                 字符串
                 * 1、字符串的不可变性
                 * 2、字符串的一坨方法:
                 * Split()
                 * Substring()
                 * ToUpper()
                 * ToLower()
                 * Trim()
                 * TrimEnd()
                 * TrimStart()
                 * Contains()
                 * Replace()
                 * IndexOf
                 * LastIndexof
                 * StartsWith
                 * EndsWith
                 * string.join()
                 * string.IsNullOrEmpty()
                 * ToCharArray()
                 * new string(char[] chs)
                 * 
                 * 继承:解决类中的代码冗余
                 * 属性、方法、构造函数 子类默认调用父类无参数的构造函数
                 * this:
                 * base:
                 * new:
                 * 
                 * 
                 * 
                 * 
                 */
            }
        }
    }
*/
    //====== 里氏转换
    /*
    using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _02里氏转换
{
    class Program
    {
        static void Main(string[] args)
        {
            ////           1、里氏转换
            ////1)、子类可以赋值给父类:如果有一个地方需要一个父类作为参数,我们可以给一个子类代替
            //  Student s = new Student();
            Person p = new Student();//s;

            //string str = string.Join("|",new string[] { "1", "2", "3", "4" });
            //Console.WriteLine(str);
            //Console.ReadKey();

            ////2)、如果父类中装的是子类对象,那么可以讲这个父类强转为子类对象。

            //is的用法
            //if (p is Student)
            //{
            //    Student ss = (Student)p;
            //    ss.StudentSayHello();
            //}
            //else
            //{
            //    Console.WriteLine("转换失败");
            //}

            //as的用法

            Student t = p as Student;
            t.StudentSayHello();
            Console.ReadKey();


        }
    }

    public class Person
    {
        public void PersonSayHello()
        {
            Console.WriteLine("我是父类");
        }
    }
    public class Student : Person
    {
        public void StudentSayHello()
        {
            Console.WriteLine("我是学生");
        }
    }
    public class Teacher : Person
    {
        public void TeacherSayHello()
        {
            Console.WriteLine("我是老师");
        }
    }


}
*/
    //====== 里氏转换练习
    using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _03里氏转换练习
{
    class Program
    {
        static void Main(string[] args)
        {
            //创建10个对象 通过一个循环 去调用他们各自打招呼的方法
            //Student s = new Student();
            //Person p = new Person();
            //ShuaiGuo sg = new ShuaiGuo();

            Person[] pers = new Person[10];
            Random r = new Random();
            for (int i = 0; i < pers.Length; i++)
            {
                int rNumber = r.Next(1, 7);
                switch (rNumber)//1-6
                {
                    case 1:
                        pers[i] = new Student();
                        break;
                    case 2:
                        pers[i] = new Teacher();
                        break;
                    case 3:
                        pers[i] = new ShuaiGuo();
                        break;
                    case 4:
                        pers[i] = new MeiLv();
                        break;
                    case 5:
                        pers[i] = new YeShou();
                        break;
                    case 6:
                        pers[i] = new Person();
                        break;
                }
            }


            for (int i = 0; i < pers.Length; i++)
            {
                // pers[i].PersonSayHi();
                if (pers[i] is Student)
                {
                    ((Student)pers[i]).StudentSayHi();
                    //  pers[i].PersonSayHi();
                }
                else if (pers[i] is Teacher)
                {
                    ((Teacher)pers[i]).TeacherSayHi();
                }
                else if (pers[i] is ShuaiGuo)
                {
                    ((ShuaiGuo)pers[i]).ShuaiGuoSayHi();
                }
                else if (pers[i] is YeShou)
                {
                    ((YeShou)pers[i]).YeShouSayHi();
                }
                else if (pers[i] is MeiLv)
                {
                    ((MeiLv)pers[i]).MeiLvSayHi();
                }
                else
                {
                    pers[i].PersonSayHi();
                }

            }
            Console.ReadKey();

        }
    }

    public class Person
    {
        public void PersonSayHi()
        {
            Console.WriteLine("我是人类");
        }
    }


    public class Student : Person
    {
        public void StudentSayHi()
        {
            Console.WriteLine("我是学生");
        }
    }

    public class Teacher : Person
    {
        public void TeacherSayHi()
        {
            Console.WriteLine("我是老师");
        }
    }


    public class MeiLv : Person
    {
        public void MeiLvSayHi()
        {
            Console.WriteLine("我是镁铝");
        }
    }


    public class ShuaiGuo : Person
    {
        public void ShuaiGuoSayHi()
        {
            Console.WriteLine("我是帅锅");
        }
    }


    public class YeShou : Person
    {
        public void YeShouSayHi()
        {
            Console.WriteLine("我是野兽");
        }
    }


}

    //====== protected访问修饰符
    using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _04protected访问修饰符
{
    class Program
    {
        static void Main(string[] args)
        {
            //public private
            Person p = new Person();

        }
    }

    public class Person
    {
        protected string _name;

        public string Name
        {
            get { return _name; }
            set { _name = value; }
        }
    }


    public class Student : Person
    {
        public void Test()
        {

        }
    }
}

    //====== ArrayList集合

using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _05ArrayList集合
{
    class Program
    {
        static void Main(string[] args)
        {
            //创建了一个集合对象
            ArrayList list = new ArrayList();
            //集合:很多数据的一个集合
            //数组:长度不可变、类型单一
            //集合的好处:长度可以任意改变  类型随便
            list.Add(1);
            list.Add(3.14);
            list.Add(true);
            list.Add("张三");
            list.Add('男');
            list.Add(5000m);
            list.Add(new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9 });
            Person p = new Person();
            list.Add(p);
            list.Add(list);
            //list.AddRange(new string[]{})
            for (int i = 0; i < list.Count; i++)
            {
                if (list[i] is Person)
                {
                    ((Person)list[i]).SayHello();
                }
                else if (list[i] is int[])
                {
                    for (int j = 0; j < ((int[])list[i]).Length; j++)
                    {
                        Console.WriteLine(((int[])list[i])[j]);
                    }
                }
                else
                {
                    Console.WriteLine(list[i]);
                }


                //Console.WriteLine(list[i]);
            }
            Console.ReadKey();
        }
    }

    public class Person
    {
        public void SayHello()
        {
            Console.WriteLine("我是人类");
        }
    }
}

    //====== ToString的问题
    using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _06ToString的问题
{
    class Program
    {
        static void Main(string[] args)
        {
            //我们将一个对象输出到控制台  默认情况下 打印的就是这个对象所在的类的命名空间
            int[] nums = { 1, 2, 3, 4, 5 };
            Console.WriteLine(nums.ToString());
            Person p = new Person();
            Console.WriteLine(p.ToString());
            Console.ReadKey();
        }
    }
    public class Person
    {
        public void SayHello()
        {
            Console.WriteLine("我是人类");
        }
    }
}

    //====== ArrayList的各种方法
    using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Collections;
namespace _07ArrayList的各种方法
{
    class Program
    {
        static void Main(string[] args)
        {
            ArrayList list = new ArrayList();
            //添加单个元素
            list.Add(true);
            list.Add(1);
            list.Add("张三");
            //添加集合元素
            list.AddRange(new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9 });
            //list.AddRange(list);

            //list.Clear();清空所有元素
            //list.Remove(true);删除单个元素 写谁就删谁
            //list.RemoveAt(0);根据下标去删除元素
            //list.RemoveRange(0, 3);根据下标去移除一定范围的元素
            // list.Sort();//升序排列
            //list.Reverse();反转
            //list.Insert(1, "插入的");在指定的位置插入一个元素
            //list.InsertRange(0, new string[] { "张三", "李四" });在指定的位置插入一个集合
            //bool b = list.Contains(1);判断是否包含某个指定的元素
            list.Add("颜世伟");
            if (!list.Contains("颜世伟"))
            {
                list.Add("颜世伟");
            }
            else
            {
                Console.WriteLine("已经有这个屌丝啦");
            }
            for (int i = 0; i < list.Count; i++)
            {
                Console.WriteLine(list[i]);
            }
            Console.ReadKey();
        }
    }
}

    //====== ArrayList集合长度的问题
    using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Collections;
namespace _08ArrayList集合长度的问题
{
    class Program
    {
        static void Main(string[] args)
        {
            ArrayList list = new ArrayList();
            list.Add(1);
            list.Add(1);
            list.Add(1);
            list.Add(1);
            list.Add(1);
            list.Add(1);
            list.Add(1);
            list.Add(1);
            list.Add(1);
            Console.WriteLine(list.Count);
            Console.WriteLine(list.Capacity);
            Console.ReadKey();
            //count 表示这个集合中实际包含的元素的个数
            //capcity 表示这个集合中可以包含的元素的个数
        }
    }
}

    //====== 集合的练习
    using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _09集合的练习
{
    class Program
    {
        static void Main(string[] args)
        {
            //创建一个集合,里面添加一些数字,求平均值与和,最大值,最小值
            //ArrayList list = new ArrayList();
            //list.AddRange(new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9 });
            //int sum = 0;
            //int max = (int)list[0];
            //for (int i = 0; i < list.Count; i++)
            //{
            //    if ((int)list[i] > max)
            //    {
            //        max = (int)list[i];
            //    }
            //    sum += (int)list[i];
            //}
            //Console.WriteLine(sum);
            //Console.WriteLine(max);
            //Console.WriteLine(sum/list.Count);
            //Console.ReadKey();
            //写一个长度为10的集合,要求在里面随机地存放10个数字(0-9),
            //但是要求所有的数字不重复
            //ArrayList list = new ArrayList();
            //Random r = new Random();
            //for (int i = 0; i <10; i++)
            //{
            //    int rNumber = r.Next(0, 10);
            //    //集合中没有这个随机数
            //    if (!list.Contains(rNumber))
            //    {
            //        list.Add(rNumber);
            //    }
            //    else//集合中有这个随机数
            //    {
            //        //一旦产生了重复的随机数 这次循环就不算数
            //        i--;
            //    }

            //}


            //for (int i = 0; i < list.Count; i++)
            //{
            //    Console.WriteLine(list[i]);
            //}
            //Console.ReadKey();



            string str = "2++b/c*d/e";
            string[] strNew = str.Split(new char[] { '+', '-', '*', '/' });



            StringBuilder sb = new StringBuilder();//capcity count

            sb.Append("12312312312312312");
            Console.WriteLine(sb.Capacity);
            //char[] chs=  {'1','2','3'};
            Console.ReadKey();

        }
    }
}

    //====== 键值对集合

using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _10键值对集合
{
    class Program
    {

        static void Main(string[] args)
        {
            //创建了一个键值对集合对象
            Hashtable ht = new Hashtable();
            ht.Add(1, "张三");
            ht.Add(2, true);
            ht.Add(3, '男');
            ht.Add(false, "错误的");
            ht.Add(5, "张三");
            ht[6] = "新来的";//这也是一种添加数据的方式
            ht[1] = "把张三干掉";
            ht.Add("abc", "cba");

            //abc----cba
            if (!ht.ContainsKey("abc"))
            {
                //ht.Add("abc", "哈哈哈");
                ht["abc"] = "哈哈哈";
            }
            else
            {
                Console.WriteLine("已经包含abc这个键!!!");
            }


            // ht.Clear(); //移除集合中所有的元素
            ht.Remove(3);

            foreach (var item in ht.Keys)
            {
                Console.WriteLine("键是-----{0}==============值是{1}", item, ht[item]);
            }
            //在键值对集合中 是根据键去找值的
            //Console.WriteLine(ht[1]);
            //Console.WriteLine(ht[2]);
            //Console.WriteLine(ht[3]);
            //Console.WriteLine(ht[false]);
            //Console.WriteLine("==================================");
            //for (int i = 0; i < ht.Count; i++)
            //{
            //    Console.WriteLine(ht[i]);
            //}
            Console.ReadKey();
        }
    }
}

    //====== var推断类型

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _11var推断类型
{
    class Program
    {
        static void Main(string[] args)
        {
            //var:根据值能够推断出来类型
            //c#是一门强类型语言:在代码当中,必须对每一个变量的类型有一个明确的定义
            //var n = 15;
            //var n2 = "张三";
            //var n3 = 3.14;
            //var n4 = 5000m;
            //var n5 = true;
            //var n6 = '男';
            //Console.WriteLine(n.GetType());
            //Console.WriteLine(n2.GetType());
            //Console.WriteLine(n3.GetType());
            //Console.WriteLine(n4.GetType());
            //Console.WriteLine(n5.GetType());
            //Console.WriteLine(n6.GetType());
            //Console.ReadKey();

            //var input;
            //input = "张三";




            //js是一门弱类型语言
            //12 3.14 true "fdsfds"  'c'  var
        }
    }
}

    //====== foreach循环
    using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _12foreach循环
{
    class Program
    {
        static void Main(string[] args)
        {
            //int[] nums = { 1, 2, 3, 4, 5, 6, 76, 7, 8, 23 };
            //for (int i = 0; i < nums.Length; i++)
            //{
            //    Console.WriteLine(nums[i]);
            //}
            //Console.WriteLine("=====================================");
            //foreach (var item in nums)
            //{
            //    Console.WriteLine(item);
            //}
            //Console.ReadKey();
            //Stopwatch sw = new Stopwatch();
            //int[] nums = new int[1000];
            ////00:00:04.2069219
            ////00:00:00.0000070
            ////00:00:00.0000121
            //sw.Start();

            //foreach (var item in nums)
            //{

            //}
            //for (int i = 0; i < nums.Length; i++)
            //{

            //}
            //sw.Stop();
            //Console.WriteLine(sw.Elapsed);
            //Console.ReadKey();



        }
    }
}


    //====== 简繁转换
    using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Collections;
namespace _13简繁转换
{
    class Program
    {
        //简体字 6000 0-5999
        //繁体字 5999 0-5998
        private const String Jian = "啊阿埃挨哎唉哀皑癌蔼矮艾碍爱隘鞍氨安俺按暗岸胺案肮昂盎凹敖熬翱袄傲奥懊澳芭捌扒叭吧笆疤巴拔跋靶把耙坝霸罢爸白柏百摆佰败拜稗斑班搬扳般颁板版扮拌伴瓣半办绊邦帮梆榜膀绑棒磅蚌镑傍谤苞胞包褒剥薄雹保堡饱宝抱报暴豹鲍爆杯碑悲卑北辈背贝钡倍狈备惫焙被奔苯本笨崩绷甭泵蹦迸逼鼻比鄙笔彼碧蓖蔽毕毙毖币庇痹闭敝弊必辟壁臂避陛鞭边编贬扁便变卞辨辩辫遍标彪膘表鳖憋别瘪彬斌濒滨宾摈兵冰柄丙秉饼炳病并玻菠播拨钵波博勃搏铂箔伯帛舶脖膊渤泊驳捕卜哺补埠不布步簿部怖擦猜裁材才财睬踩采彩菜蔡餐参蚕残惭惨灿苍舱仓沧藏操糙槽曹草厕策侧册测层蹭插叉茬茶查碴搽察岔差诧拆柴豺搀掺蝉馋谗缠铲产阐颤昌猖场尝常长偿肠厂敞畅唱倡超抄钞朝嘲潮巢吵炒车扯撤掣彻澈郴臣辰尘晨忱沉陈趁衬撑称城橙成呈乘程惩澄诚承逞骋秤吃痴持匙池迟弛驰耻齿侈尺赤翅斥炽充冲虫崇宠抽酬畴踌稠愁筹仇绸瞅丑臭初出橱厨躇锄雏滁除楚础储矗搐触处揣川穿椽传船喘串疮窗幢床闯创吹炊捶锤垂春椿醇唇淳纯蠢戳绰疵茨磁雌辞慈瓷词此刺赐次聪葱囱匆从丛凑粗醋簇促蹿篡窜摧崔催脆瘁粹淬翠村存寸磋撮搓措挫错搭达答瘩打大呆歹傣戴带殆代贷袋待逮怠耽担丹单郸掸胆旦氮但惮淡诞弹蛋当挡党荡档刀捣蹈倒岛祷导到稻悼道盗德得的蹬灯登等瞪凳邓堤低滴迪敌笛狄涤翟嫡抵底地蒂第帝弟递缔颠掂滇碘点典靛垫电佃甸店惦奠淀殿碉叼雕凋刁掉吊钓调跌爹碟蝶迭谍叠丁盯叮钉顶鼎锭定订丢东冬董懂动栋侗恫冻洞兜抖斗陡豆逗痘都督毒犊独读堵睹赌杜镀肚度渡妒端短锻段断缎堆兑队对墩吨蹲敦顿囤钝盾遁掇哆多夺垛躲朵跺舵剁惰堕蛾峨鹅俄额讹娥恶厄扼遏鄂饿恩而儿耳尔饵洱二贰发罚筏伐乏阀法珐藩帆番翻樊矾钒繁凡烦反返范贩犯饭泛坊芳方肪房防妨仿访纺放菲非啡飞肥匪诽吠肺废沸费芬酚吩氛分纷坟焚汾粉奋份忿愤粪丰封枫蜂峰锋风疯烽逢冯缝讽奉凤佛否夫敷肤孵扶拂辐幅氟符伏俘服浮涪福袱弗甫抚辅俯釜斧脯腑府腐赴副覆赋复傅付阜父腹负富讣附妇缚咐噶嘎该改概钙盖溉干甘杆柑竿肝赶感秆敢赣冈刚钢缸肛纲岗港杠篙皋高膏羔糕搞镐稿告哥歌搁戈鸽胳疙割革葛格蛤阁隔铬个各给根跟耕更庚羹埂耿梗工攻功恭龚供躬公宫弓巩汞拱贡共钩勾沟苟狗垢构购够辜菇咕箍估沽孤姑鼓古蛊骨谷股故顾固雇刮瓜剐寡挂褂乖拐怪棺关官冠观管馆罐惯灌贯光广逛瑰规圭硅归龟闺轨鬼诡癸桂柜跪贵刽辊滚棍锅郭国果裹过哈骸孩海氦亥害骇酣憨邯韩含涵寒函喊罕翰撼捍旱憾悍焊汗汉夯杭航壕嚎豪毫郝好耗号浩呵喝荷菏核禾和何合盒貉阂河涸赫褐鹤贺嘿黑痕很狠恨哼亨横衡恒轰哄烘虹鸿洪宏弘红喉侯猴吼厚候后呼乎忽瑚壶葫胡蝴狐糊湖弧虎唬护互沪户花哗华猾滑画划化话槐徊怀淮坏欢环桓还缓换患唤痪豢焕涣宦幻荒慌黄磺蝗簧皇凰惶煌晃幌恍谎灰挥辉徽恢蛔回毁悔慧卉惠晦贿秽会烩汇讳诲绘荤昏婚魂浑混豁活伙火获或惑霍货祸击圾基机畸稽积箕肌饥迹激讥鸡姬绩缉吉极棘辑籍集及急疾汲即嫉级挤几脊己蓟技冀季伎祭剂悸济寄寂计记既忌际继纪嘉枷夹佳家加荚颊贾甲钾假稼价架驾嫁歼监坚尖笺间煎兼肩艰奸缄茧检柬碱硷拣捡简俭剪减荐槛鉴践贱见键箭件健舰剑饯渐溅涧建僵姜将浆江疆蒋桨奖讲匠酱降蕉椒礁焦胶交郊浇骄娇嚼搅铰矫侥脚狡角饺缴绞剿教酵轿较叫窖揭接皆秸街阶截劫节茎睛晶鲸京惊精粳经井警景颈静境敬镜径痉靖竟竞净炯窘揪究纠玖韭久灸九酒厩救旧臼舅咎就疚鞠拘狙疽居驹菊局咀矩举沮聚拒据巨具距踞锯俱句惧炬剧捐鹃娟倦眷卷绢撅攫抉掘倔爵桔杰捷睫竭洁结解姐戒藉芥界借介疥诫届巾筋斤金今津襟紧锦仅谨进靳晋禁近烬浸尽劲荆兢觉决诀绝均菌钧军君峻俊竣浚郡骏喀咖卡咯开揩楷凯慨刊堪勘坎砍看康慷糠扛抗亢炕考拷烤靠坷苛柯棵磕颗科壳咳可渴克刻客课肯啃垦恳坑吭空恐孔控抠口扣寇枯哭窟苦酷库裤夸垮挎跨胯块筷侩快宽款匡筐狂框矿眶旷况亏盔岿窥葵奎魁傀馈愧溃坤昆捆困括扩廓阔垃拉喇蜡腊辣啦莱来赖蓝婪栏拦篮阑兰澜谰揽览懒缆烂滥琅榔狼廊郎朗浪捞劳牢老佬姥酪烙涝勒乐雷镭蕾磊累儡垒擂肋类泪棱楞冷厘梨犁黎篱狸离漓理李里鲤礼莉荔吏栗丽厉励砾历利傈例俐痢立粒沥隶力璃哩俩联莲连镰廉怜涟帘敛脸链恋炼练粮凉梁粱良两辆量晾亮谅撩聊僚疗燎寥辽潦了撂镣廖料列裂烈劣猎琳林磷霖临邻鳞淋凛赁吝拎玲菱零龄铃伶羚凌灵陵岭领另令溜琉榴硫馏留刘瘤流柳六龙聋咙笼窿隆垄拢陇楼娄搂篓漏陋芦卢颅庐炉掳卤虏鲁麓碌露路赂鹿潞禄录陆戮驴吕铝侣旅履屡缕虑氯律率滤绿峦挛孪滦卵乱掠略抡轮伦仑沦纶论萝螺罗逻锣箩骡裸落洛骆络妈麻玛码蚂马骂嘛吗埋买麦卖迈脉瞒馒蛮满蔓曼慢漫谩芒茫盲氓忙莽猫茅锚毛矛铆卯茂冒帽貌贸么玫枚梅酶霉煤没眉媒镁每美昧寐妹媚门闷们萌蒙檬盟锰猛梦孟眯醚靡糜迷谜弥米秘觅泌蜜密幂棉眠绵冕免勉娩缅面苗描瞄藐秒渺庙妙蔑灭民抿皿敏悯闽明螟鸣铭名命谬摸摹蘑模膜磨摩魔抹末莫墨默沫漠寞陌谋牟某拇牡亩姆母墓暮幕募慕木目睦牧穆拿哪呐钠那娜纳氖乃奶耐奈南男难囊挠脑恼闹淖呢馁内嫩能妮霓倪泥尼拟你匿腻逆溺蔫拈年碾撵捻念娘酿鸟尿捏聂孽啮镊镍涅您柠狞凝宁拧泞牛扭钮纽脓浓农弄奴努怒女暖虐疟挪懦糯诺哦欧鸥殴藕呕偶沤啪趴爬帕怕琶拍排牌徘湃派攀潘盘磐盼畔判叛乓庞旁耪胖抛咆刨炮袍跑泡呸胚培裴赔陪配佩沛喷盆砰抨烹澎彭蓬棚硼篷膨朋鹏捧碰坯砒霹批披劈琵毗啤脾疲皮匹痞僻屁譬篇偏片骗飘漂瓢票撇瞥拼频贫品聘乒坪苹萍平凭瓶评屏坡泼颇婆破魄迫粕剖扑铺仆莆葡菩蒲埔朴圃普浦谱曝瀑期欺栖戚妻七凄漆柒沏其棋奇歧畦崎脐齐旗祈祁骑起岂乞企启契砌器气迄弃汽泣讫掐洽牵扦钎铅千迁签仟谦乾黔钱钳前潜遣浅谴堑嵌欠歉枪呛腔羌墙蔷强抢橇锹敲悄桥瞧乔侨巧鞘撬翘峭俏窍切茄且怯窃钦侵亲秦琴勤芹擒禽寝沁青轻氢倾卿清擎晴氰情顷请庆琼穷秋丘邱球求囚酋泅趋区蛆曲躯屈驱渠取娶龋趣去圈颧权醛泉全痊拳犬券劝缺炔瘸却鹊榷确雀裙群然燃冉染瓤壤攘嚷让饶扰绕惹热壬仁人忍韧任认刃妊纫扔仍日戎茸蓉荣融熔溶容绒冗揉柔肉茹蠕儒孺如辱乳汝入褥软阮蕊瑞锐闰润若弱撒洒萨腮鳃塞赛三叁伞散桑嗓丧搔骚扫嫂瑟色涩森僧莎砂杀刹沙纱傻啥煞筛晒珊苫杉山删煽衫闪陕擅赡膳善汕扇缮墒伤商赏晌上尚裳梢捎稍烧芍勺韶少哨邵绍奢赊蛇舌舍赦摄射慑涉社设砷申呻伸身深娠绅神沈审婶甚肾慎渗声生甥牲升绳省盛剩胜圣师失狮施湿诗尸虱十石拾时什食蚀实识史矢使屎驶始式示士世柿事拭誓逝势是嗜噬适仕侍释饰氏市恃室视试收手首守寿授售受瘦兽蔬枢梳殊抒输叔舒淑疏书赎孰熟薯暑曙署蜀黍鼠属术述树束戍竖墅庶数漱恕刷耍摔衰甩帅栓拴霜双爽谁水睡税吮瞬顺舜说硕朔烁斯撕嘶思私司丝死肆寺嗣四伺似饲巳松耸怂颂送宋讼诵搜艘擞嗽苏酥俗素速粟僳塑溯宿诉肃酸蒜算虽隋随绥髓碎岁穗遂隧祟孙损笋蓑梭唆缩琐索锁所塌他它她塔獭挞蹋踏胎苔抬台泰酞太态汰坍摊贪瘫滩坛檀痰潭谭谈坦毯袒碳探叹炭汤塘搪堂棠膛唐糖倘躺淌趟烫掏涛滔绦萄桃逃淘陶讨套特藤腾疼誊梯剔踢锑提题蹄啼体替嚏惕涕剃屉天添填田甜恬舔腆挑条迢眺跳贴铁帖厅听烃汀廷停亭庭挺艇通桐酮瞳同铜彤童桶捅筒统痛偷投头透凸秃突图徒途涂屠土吐兔湍团推颓腿蜕褪退吞屯臀拖托脱鸵陀驮驼椭妥拓唾挖哇蛙洼娃瓦袜歪外豌弯湾玩顽丸烷完碗挽晚皖惋宛婉万腕汪王亡枉网往旺望忘妄威巍微危韦违桅围唯惟为潍维苇萎委伟伪尾纬未蔚味畏胃喂魏位渭谓尉慰卫瘟温蚊文闻纹吻稳紊问嗡翁瓮挝蜗涡窝我斡卧握沃巫呜钨乌污诬屋无芜梧吾吴毋武五捂午舞伍侮坞戊雾晤物勿务悟误昔熙析西硒矽晰嘻吸锡牺稀息希悉膝夕惜熄烯溪汐犀檄袭席习媳喜铣洗系隙戏细瞎虾匣霞辖暇峡侠狭下厦夏吓掀锨先仙鲜纤咸贤衔舷闲涎弦嫌显险现献县腺馅羡宪陷限线相厢镶香箱襄湘乡翔祥详想响享项巷橡像向象萧硝霄削哮嚣销消宵淆晓小孝校肖啸笑效楔些歇蝎鞋协挟携邪斜胁谐写械卸蟹懈泄泻谢屑薪芯锌欣辛新忻心信衅星腥猩惺兴刑型形邢行醒幸杏性姓兄凶胸匈汹雄熊休修羞朽嗅锈秀袖绣墟戌需虚嘘须徐许蓄酗叙旭序畜恤絮婿绪续轩喧宣悬旋玄选癣眩绚靴薛学穴雪血勋熏循旬询寻驯巡殉汛训讯逊迅压押鸦鸭呀丫芽牙蚜崖衙涯雅哑亚讶焉咽阉烟淹盐严研蜒岩延言颜阎炎沿奄掩眼衍演艳堰燕厌砚雁唁彦焰宴谚验殃央鸯秧杨扬佯疡羊洋阳氧仰痒养样漾邀腰妖瑶摇尧遥窑谣姚咬舀药要耀椰噎耶爷野冶也页掖业叶曳腋夜液一壹医揖铱依伊衣颐夷遗移仪胰疑沂宜姨彝椅蚁倚已乙矣以艺抑易邑屹亿役臆逸肄疫亦裔意毅忆义益溢诣议谊译异翼翌绎茵荫因殷音阴姻吟银淫寅饮尹引隐印英樱婴鹰应缨莹萤营荧蝇迎赢盈影颖硬映哟拥佣臃痈庸雍踊蛹咏泳涌永恿勇用幽优悠忧尤由邮铀犹油游酉有友右佑釉诱又幼迂淤于盂榆虞愚舆余俞逾鱼愉渝渔隅予娱雨与屿禹宇语羽玉域芋郁吁遇喻峪御愈欲狱育誉浴寓裕预豫驭鸳渊冤元垣袁原援辕园员圆猿源缘远苑愿怨院曰约越跃钥岳粤月悦阅耘云郧匀陨允运蕴酝晕韵孕匝砸杂栽哉灾宰载再在咱攒暂赞赃脏葬遭糟凿藻枣早澡蚤躁噪造皂灶燥责择则泽贼怎增憎曾赠扎喳渣札轧铡闸眨栅榨咋乍炸诈摘斋宅窄债寨瞻毡詹粘沾盏斩辗崭展蘸栈占战站湛绽樟章彰漳张掌涨杖丈帐账仗胀瘴障招昭找沼赵照罩兆肇召遮折哲蛰辙者锗蔗这浙珍斟真甄砧臻贞针侦枕疹诊震振镇阵蒸挣睁征狰争怔整拯正政帧症郑证芝枝支吱蜘知肢脂汁之织职直植殖执值侄址指止趾只旨纸志挚掷至致置帜峙制智秩稚质炙痔滞治窒中盅忠钟衷终种肿重仲众舟周州洲诌粥轴肘帚咒皱宙昼骤珠株蛛朱猪诸诛逐竹烛煮拄瞩嘱主著柱助蛀贮铸筑住注祝驻抓爪拽专砖转撰赚篆桩庄装妆撞壮状椎锥追赘坠缀谆准捉拙卓桌琢茁酌啄着灼浊兹咨资姿滋淄孜紫仔籽滓子自渍字鬃棕踪宗综总纵邹走奏揍租足卒族祖诅阻组钻纂嘴醉最罪尊遵昨左佐柞做作坐座";
        private const String Fan = "啊阿埃挨哎唉哀皚癌藹矮艾礙愛隘鞍氨咹俺按暗岸胺案肮昂盎凹敖熬翱襖傲奧懊澳芭捌扒叭吧笆疤巴拔跋靶紦耙壩霸罷爸苩柏百擺佰敗拜稗斑癍搬扳般頒板蝂扮拌伴瓣半か絆邦幫梆榜膀綁棒磅蚌鎊傍謗苞胞包褒剝薄雹保堡飽寶菢報暴豹鮑爆杯碑悲卑丠輩褙贔鋇倍狽備憊焙被奔苯夲笨崩繃甭泵蹦迸逼鼻仳鄙筆彼碧蓖蔽畢斃毖幣庇痹閉敝弊必辟壁臂避陛鞭邊編貶扁便變卞辨辯辮遍標彪膘表鱉憋別癟彬斌瀕濱賓擯兵栤柄丙秉餅炳疒並箥菠播撥缽波博葧搏鉑箔伯帛舶脖膊渤泊駁捕卜哺補埠鈈咘步簿蔀怖擦猜裁材才財睬踩采彩菜蔡餐參蠶殘慚慘燦蒼艙倉滄藏操糙槽曹草廁策側冊測層蹭插叉茬茶查碴搽察岔差詫拆柴豺攙摻蟬饞讒纏鏟產闡顫昌猖場嘗瑺長償腸廠敞暢唱倡超抄鈔朝嘲潮巢吵炒車扯撤掣徹澈郴臣辰塵晨忱沉陳趁襯撐稱城橙成呈乘程懲澄誠承逞騁秤吃癡持匙池遲弛馳恥齒侈尺赤翅斥熾充沖蟲崇寵抽酬疇躊稠愁籌仇綢瞅醜臭初絀櫥廚躇鋤雛滁除楚礎儲矗搐觸處揣〣穿椽傳船喘串瘡窗幢床闖創吹炊捶錘垂春椿醇唇淳純蠢戳綽疵茨磁雌辭慈瓷詞此刺賜佽聰蔥囪匆從叢湊粗醋簇促躥篡竄摧崔催脆瘁粹淬翠村存団磋撮搓措挫諎搭達答瘩咑夶槑歹傣戴帶殆玳貸袋待逮怠耽擔丼單鄲撣膽旦氮但憚淡誕彈蜑當擋黨蕩檔刀搗蹈倒島禱導箌稻悼噵盜德嘚啲蹬燈登等瞪凳鄧堤低滴迪敵笛狄滌翟嫡抵底地蒂第渧弟遞締顛掂滇碘點典靛墊電佃甸店惦奠澱殿碉叼雕凋刁掉吊釣調跌爹碟蝶迭諜疊丁盯叮釘頂鼎錠萣訂丟東冬董懂動棟侗恫凍洞兜抖鬥陡豆逗痘都督蝳犢獨讀堵睹賭杜鍍肚喥渡妒端短鍛段斷緞堆兌隊對墩噸蹲敦頓囤鈍盾遁掇哆哆奪垛躲朵跺舵剁惰墮蛾峨鵝俄額訛娥惡厄扼遏鄂餓恩洏ㄦ聑爾餌洱②貳發罰筏伐乏閥法琺藩帆番翻樊礬釩繁凡煩反返范販犯飯泛坊芳方肪房防妨仿訪紡放菲非啡飝肥匪誹吠肺廢沸費芬酚吩氛汾紛墳焚汾粉奮份忿憤糞豐葑楓蜂峰鋒闏瘋烽逢馮縫諷奉鳳佛否夫敷膚孵扶拂輻幅氟符伏俘垺浮涪鍢袱弗甫撫輔俯釜斧脯腑府腐赴副覆賦複傅付阜父腹負富訃附婦縛咐噶嘎該改概鈣蓋溉幹咁杆柑竿肝趕感稈敢贛岡剛鋼缸肛綱崗港杠篙皋高膏羔糕搞鎬稿告哥歌擱戈鴿胳疙割革葛格蛤閣隔鉻個各給根哏耕哽庚羹埂耿梗工攻功恭龔供躬公宮弓鞏汞拱貢囲鉤勾溝苟狗垢構購夠辜菇咕箍估沽孤姑鼓古蠱骨穀股故顧固雇刮瓜剮寡掛褂乖拐怪棺關官冠觀管館罐慣灌貫咣廣逛瑰規圭矽歸龜閨軌鬼詭癸桂櫃跪圚劊輥滾棍鍋郭國果裹過囧骸駭海氦亥害駭酣憨邯韓含涵寒函喊罕翰撼捍旱憾悍焊汗漢夯杭航壕嚎豪毫郝恏耗號浩呵喝荷菏核禾囷何匼盒貉閡河涸赫褐鶴賀嘿嫼痕很狠恨哼亨橫衡恒轟哄烘虹鴻洪宏弘紅喉侯猴吼厚候後呼乎忽瑚壺葫胡蝴狐糊鍸弧虤唬護互滬戶婲嘩囮猾滑畫劃囮話槐徊懷淮壞歡環桓還緩換患喚瘓豢煥渙宦幻荒慌黃磺蝗簧瑝凰惶煌晃幌恍謊咴揮輝徽恢蛔囙毀悔慧卉惠晦賄穢茴燴彙諱誨繪葷昏婚魂渾混豁活夥吙獲戓惑霍貨禍擊圾基機畸稽積箕肌饑跡噭譏雞姬績緝吉極棘輯籍集及ゑ疾汲即嫉級擠幾脊己薊技冀季伎祭劑悸濟寄寂計記既忌際繼紀嘉枷夾佳镓加莢頰賈甲鉀假稼價架駕嫁殲監堅尖箋間煎兼肩艱奸緘繭檢柬堿鹼揀撿簡儉剪減薦檻鑒踐賤見鍵箭件健艦劍餞漸濺澗建僵薑將漿江疆蔣槳獎講匠醬降蕉椒礁焦膠交郊澆驕嬌嚼攪鉸矯僥腳狡角餃繳絞剿教酵轎較叫窖揭接皆秸街階截劫節莖聙晶鯨京驚精粳經囲警景頸靜境敬鏡徑痙靖竟競淨炯窘揪究糾玖韭久灸九酒廄救舊臼舅咎就疚鞠拘狙疽居駒菊局咀矩舉沮聚拒據巨具距踞鋸俱句懼炬劇捐鵑娟倦眷卷絹撅攫抉掘倔爵桔傑捷睫竭潔結解姐戒藉芥堺借介疥誡屆巾筋斤金紟津襟緊錦僅謹進靳晉禁近燼浸盡勁荊兢覺決訣絕均菌鈞軍君峻俊竣浚郡駿喀咖鉲咯開揩楷凱慨刊堪勘坎砍看康慷糠扛抗亢炕考拷烤靠坷苛柯棵磕顆科殼咳鈳渴克刻愙課肯啃墾懇坑吭涳恐孔控摳ロ扣寇枯哭窟苦酷庫褲誇垮挎跨胯塊筷儈快寬款匡筐狂框礦眶曠況虧盔巋窺葵奎魁傀饋愧潰坤昆捆困括擴廓闊垃拉喇蠟臘辣啦萊唻賴藍婪欄攔籃闌蘭瀾讕攬覽懶纜爛濫琅榔狼廊郎朗浪撈勞牢咾佬姥酪烙澇勒圞雷鐳蕾磊累儡壘擂肋類淚棱楞冷厘梨犁黎籬狸離漓悝李裏鯉禮莉荔吏栗麗厲勵礫曆利傈例俐痢竝粒瀝隸仂璃哩倆聯蓮連鐮廉憐漣簾斂臉鏈戀煉練糧涼梁粱良両輛量晾煷諒撩聊僚療燎寥遼潦叻撂鐐廖料列裂烮劣獵琳林磷霖臨鄰鱗淋凜賃吝拎玲菱零齡鈴伶羚淩靈陵嶺領另囹溜琉榴硫餾留劉瘤鋶柳六龖聾嚨籠窿隆壟攏隴嘍婁摟簍漏陋蘆盧顱廬爐擄鹵虜魯麓碌露蕗賂麤潞祿錄陸戮驢呂鋁侶旅履屢縷慮氯律率濾綠巒攣孿灤卵亂掠略掄輪倫侖淪綸論蘿螺羅邏鑼籮騾裸落洛駱絡媽麻瑪碼螞骉罵嘛嗎埋買麥賣邁脈瞞饅蠻滿蔓曼慢漫謾芒茫吂氓忙莽貓茅錨毛矛鉚卯茂冒帽貌貿仫玫枚梅酶黴煤莈眉媒鎂烸媄昧寐妹媚闁悶們萌蒙檬盟錳猛夢孟眯醚靡糜迷謎彌米秘覓泌蜜密冪棉眠綿冕免勉娩緬面苗描瞄藐秒渺廟妙蔑滅囻抿皿敏憫閩朙螟鳴銘名命謬摸摹蘑模膜磨摩魔抹末莫墨默沫漠寞陌謀牟某拇牡畝姆毋墓暮幕募慕朩目睦牧穆拿哪呐鈉那娜納氖乃奶耐奈喃侽難囊撓腦惱鬧淖呢餒內嫩能妮霓倪苨胒擬伱匿膩逆溺蔫拈姩碾攆撚念娘釀茑尿捏聶孽齧鑷鎳涅您檸獰凝寧擰濘犇扭鈕紐膿濃農弄奴努怒囡暖虐瘧挪懦糯諾哦歐鷗毆藕嘔偶漚啪趴爬帕怕琶拍排牌徘湃派攀潘盤磐盼畔判叛乓龐旁耪胖拋咆刨炮袍跑泡呸胚培裴賠陪配佩沛噴盆砰抨烹澎彭蓬棚硼篷膨萠鵬捧碰坯砒霹批披劈琵毗啤脾疲皮匹痞僻屁譬篇偏爿騙飄漂瓢票撇瞥拼頻貧品聘乒坪蘋萍平憑瓶評屏坡潑頗嘙破魄迫粕剖撲鋪仆莆葡菩蒲埔樸圃普浦譜曝瀑期欺棲戚妻七淒漆柒沏其棋奇歧畦崎臍齊旗祈祁騎起豈乞企啟契砌器気迄棄汽泣訖掐洽牽扡釺鉛芉遷簽仟謙乾黔錢鉗前潛遣淺譴塹嵌欠歉槍嗆腔羌牆薔強搶橇鍬敲悄橋瞧喬僑巧鞘撬翹峭俏竅切茄且怯竊欽侵儭秦琴勤芹擒禽寢沁圊輕氫傾卿清擎晴氰情頃請慶瓊窮秋丘邱浗求囚酋泅趨區蛆曲軀屈驅渠取娶齲趣去圈顴權醛灥铨痊拳猋券勸缺炔瘸卻鵲榷確雀裙群然燃冉染瓤壤攘嚷讓饒擾繞惹熱壬仁囚忍韌任認刃妊紉扔仍ㄖ戎茸蓉榮融熔溶容絨冗揉柔禸茹蠕儒孺洳辱乳汝入褥軟阮蕊瑞銳閏潤若弱撒灑薩腮鰓塞賽三三傘散桑嗓喪搔騷掃嫂瑟銫澀森僧莎砂殺刹沙紗儍啥煞篩曬珊苫杉屾刪煽衫閃陝擅贍膳善汕扇繕墒傷商賞晌仩尚裳梢捎稍燒芍勺韶尐哨邵紹奢賒蛇舌舍赦攝射懾涉社設砷申呻伸身深娠紳神沈審嬸甚腎慎滲聲苼甥牲升繩渻盛剩勝聖師夨獅施濕詩屍虱┿石拾塒什喰蝕實識史矢使屎駛始式示壵卋柿倳拭誓逝勢昰嗜噬適仕侍釋飾氏市恃室視試收掱首垨壽授售受瘦獸蔬樞梳殊抒輸菽舒淑疏圕贖孰熟薯暑曙署蜀黍鼠屬術述樹束戍豎墅庶數漱恕刷耍摔衰甩帥栓拴霜雙爽誰沝睡稅吮瞬順舜詤碩朔爍斯撕嘶思私司絲迉肆寺嗣四伺似飼巳松聳慫頌送宋訟誦搜艘擻嗽蘇酥俗素速粟僳塑溯宿訴肅酸蒜算雖隋隨綏髓誶歲穗遂隧祟孫損筍蓑梭唆縮瑣索鎖所塌彵咜她塔獺撻蹋踏胎苔抬囼泰酞呔態汰坍攤貪癱灘壇檀痰潭譚談坦毯袒碳探歎炭湯塘搪堂棠膛唐糖倘躺淌趟燙掏濤滔絛萄桃逃淘陶討套特藤騰疼謄梯剔踢銻提題蹄啼體替嚏惕涕剃屜兲添填畾憇恬舔腆挑條迢眺跳貼鐵帖廳聽烴汀廷停亭庭挺艇通桐酮瞳哃銅彤童桶捅筒統痛偷投頭透凸禿突圖徒途塗屠汢吐兔湍團推穨腿蛻褪退吞屯臀拖托脫鴕陀馱駝橢妥拓唾挖哇蛙窪娃瓦襪歪外豌彎灣玩頑丸烷完碗挽晚皖惋宛婉萬腕汪迋亡枉網往旺望莣妄威巍微危韋違桅圍唯惟為濰維葦萎委偉偽尾緯未蔚菋畏胃喂魏位渭謂尉慰衛瘟溫蚊攵聞紋吻穩紊問嗡翁甕撾蝸渦窩莪斡臥握沃莁嗚鎢烏汙誣屋無蕪梧吾吳毋武五捂午舞伍侮塢戊霧晤粅勿務悟誤昔熙析覀硒矽晰嘻吸錫犧稀息希悉膝夕惜熄烯溪汐犀檄襲席習媳囍銑洗系隙戲細瞎蝦匣霞轄暇峽俠狹丅廈夏嚇掀鍁先仙鮮纖鹹賢銜舷閑涎弦嫌顯險哯獻縣腺餡羨憲陷限線相廂鑲馫箱襄湘鄉翔祥詳想響享項巷橡像姠潒蕭硝霄削哮囂銷消宵淆曉曉孝校肖嘯笑效楔些歇蠍鞋協挾攜邪斜脅諧寫械卸蟹懈泄瀉謝屑薪芯鋅欣辛噺忻惢信釁煋腥猩惺興刑型形邢荇醒圉杏性姓兄凶胸匈洶雄熊休修羞朽嗅鏽秀袖繡墟戌需虛噓須徐許蓄酗敘旭序畜恤絮婿緒續軒喧宣懸旋玄選癬眩絢靴薛學穴雪血勳熏循旬詢尋馴巡殉汛訓訊遜迅壓押鴉鴨吖丫芽牙蚜崖衙涯雅啞亜訝焉咽閹煙淹鹽嚴研蜒岩延訁顏閻燚沿奄掩眼衍演豔堰燕厭硯雁唁彥焰宴諺驗殃央鴦秧楊揚佯瘍羴洋陽氧仰癢養樣漾邀腰妖瑤搖堯遙窯謠姚咬舀藥偠耀椰噎耶爺野冶吔頁掖業旪曳腋夜液┅壹醫揖銥依伊衤頤夷遺移儀胰疑沂宜姨彝椅蟻倚巳乙矣鉯藝抑噫邑屹億役臆逸肄疫亦裔意毅憶図益溢詣議誼譯異翼翌繹茵蔭因殷喑陰姻吟銀淫寅飲尹引隱茚英櫻嬰鷹應纓瑩螢營熒蠅迎贏盈影穎硬映喲擁傭臃癰庸雍踴蛹詠泳湧詠恿勇鼡幽優悠憂尤由郵鈾猶油遊酉洧伖右佑釉誘又呦迂淤於盂榆虞愚輿餘俞逾鱻愉渝漁隅予娛雨與嶼禹宇語羽玊域芋鬱籲遇喻峪禦愈欲獄育譽浴寓裕預豫馭鴛淵冤え垣袁原援轅園員圓猿源緣遠苑願怨院曰約越躍鑰嶽粵仴悅閱耘雲鄖勻隕尣運蘊醞暈韻孕匝砸雜栽哉災宰載洅茬咱攢暫贊贓贓葬遭糟鑿藻棗早澡蚤躁噪造皂灶燥責擇則澤賊怎增憎曾贈紮喳渣劄軋鍘閘眨柵榨咋乍炸詐摘齋宅窄債寨瞻氈詹粘沾盞斬輾嶄展蘸棧占戰站湛綻樟嶂彰漳涨掌漲杖丈帳賬仗脹瘴障招昭找沼趙照罩兆肇召遮折哲蟄轍者鍺蔗這浙珍斟眞甄砧臻貞針偵枕疹診震振鎮陣蒸掙睜征猙爭怔整拯㊣政幀症鄭證芝枝支吱蜘知肢脂汁の織職直植殖執徝侄址指止趾呮旨紙志摯擲至致置幟峙制智秩稚質炙痔滯治窒ф盅忠鍾衷終種腫重仲眾舟周州洲謅粥軸肘帚咒皺宙晝驟珠株蛛朱豬諸誅逐竹燭煮拄矚囑主著柱助蛀貯鑄築住紸祝駐抓爪拽專磚轉撰賺篆樁莊裝妝撞壯狀椎錐縋贅墜綴諄准捉拙卓桌琢茁酌啄著灼濁茲咨資姿滋淄孜紫仔籽滓孓自漬芓鬃棕蹤宗綜總縱鄒赱奏揍租足卒族祖詛阻組鑽纂嘴醉朂罪尊遵昨咗佐柞做作唑座";
        static void Main(string[] args)
        {
            Hashtable ht = new Hashtable();
            for (int i = 0; i < Jian.Length; i++)
            {
                ht.Add(Jian[i], Fan[i]);
            }
            Console.WriteLine("请随便输入");
            string input = Console.ReadLine();//张三abc李四
            //遍历用户输入的字符串 将每一个字符都转换成繁体字
            for (int i = 0; i < input.Length; i++)
            {
                if (ht.ContainsKey(input[i]))
                {
                    Console.Write(ht[input[i]]);
                }
                else
                {
                    Console.Write(input[i]);
                }
            }
            Console.ReadKey();
            //将用户输入的简体字 转换成繁体字
        }
    }
}

    //====== Path类

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _14Path类
{
    class Program
    {
        static void Main(string[] args)
        {
            string str = @"C:\3000soft\Red Spider\Data\Message\老赵.wav";
            //获得文件名
            Console.WriteLine(Path.GetFileName(str));
            //获得文件名但是不包含扩展名
            Console.WriteLine(Path.GetFileNameWithoutExtension(str));
            //获得文件的扩展名
            Console.WriteLine(Path.GetExtension(str));
            //获得文件所在的文件夹的名称
            Console.WriteLine(Path.GetDirectoryName(str));
            //获得文件所在的全路径
            Console.WriteLine(Path.GetFullPath(str));
            //连接两个字符串作为路径
            Console.WriteLine(Path.Combine(@"c:\a\", "b.txt"));


            //int index = str.LastIndexOf("\\");
            //str = str.Substring(index + 1);
            //Console.WriteLine(str);
            Console.ReadKey();
        }
    }
}

    //====== File类
    using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _15File类
{
    class Program
    {
        static void Main(string[] args)
        {

            //创建一个文件
            //File.Create(@"C:\Users\SpringRain\Desktop\new.txt");
            //Console.WriteLine("创建成功");
            //Console.ReadKey();

            //删除一个文件
            //File.Delete(@"C:\Users\SpringRain\Desktop\new.txt");
            //Console.WriteLine("删除成功");
            //Console.ReadKey();
            //1024byte=1kb
            //1024kb=1M
            //1024M=1G
            //1024G=1T
            //1024T=1PT

            //复制一个文件
            //File.Copy(@"C:\Users\SpringRain\Desktop\code.txt", @"C:\Users\SpringRain\Desktop\new.txt");
            //Console.WriteLine("复制成功");
            //Console.ReadKey();


            //剪切
            File.Move(@"C:\Users\SpringRain\Desktop\code.txt", @"C:\Users\SpringRain\Desktop\newnew.txt");
            Console.WriteLine("剪切成功");
            Console.ReadKey();


            //Console.WriteLine(sizeof(char));
            //Console.ReadKey();
            //Console.WriteLine(sizeof(string));a  "dsfdsfds"
            //Console.ReadKey();
        }
    }
}

    //====== 复习

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Collections;
using System.IO;
namespace _01复习
{
    class Program
    {
        static void Main(string[] args)
        {
            /*
             里氏转换:
             * 1、子类可以赋值给父类(如果有一个方法需要一个父类作为参数,我们可以传第一个子类对象)
             * 2、如果父类中装的是子类对象,则可以将这个父类强转为子类对象
             */

            //Person p = new Student();
            ////is as
            //Student ss = p as Student;
            //ss.StudentSayHello();
            //Console.ReadKey();
            //if (p is Student)
            //{
            //    ((Student)p).StudentSayHello();
            //}
            //else
            //{
            //    Console.WriteLine("转换失败");
            //}
            //Console.ReadKey();


            //ArrayList list = new ArrayList();
            //Remove RemoveAt  RemoveRange  Clear  Insert  InsertRange
            //Reverse  Sort

            //Hashtable ht = new Hashtable();
            //ht.Add(1, "张三");
            //ht.Add(true, '男');
            //ht.Add(3.14, 5000m);
            ////在键值对集合中 键必须是唯一的
            ////ht.Add(1, "李四");
            //ht[1] = "李四";
            ////ht.ContainsKey
            //foreach (var item in ht.Keys)
            //{
            //    Console.WriteLine("{0}------------{1}",item,ht[item]);
            //}
            //Console.ReadKey();

            //Path


            //File
            //Create  Delete Copy Move

            //byte[] buffer = File.ReadAllBytes(@"C:\Users\SpringRain\Desktop\抽象类特点.txt");
            ////将字节数组中的每一个元素都要按照我们指定的编码格式解码成字符串
            ////UTF-8  GB2312 GBK ASCII  Unicode
            //string s = Encoding.Default.GetString(buffer);

            //Console.WriteLine(s);
            //Console.ReadKey();

            //没有这个文件的话 会给你创建一个 有的话 会给你覆盖掉
            //string str="今天天气好晴朗处处好风光";
            ////需要将字符串转换成字节数组
            //byte[] buffer= Encoding.Default.GetBytes(str);
            //File.WriteAllBytes(@"C:\Users\SpringRain\Desktop\new.txt", buffer);
            //Console.WriteLine("写入成功");
            //Console.ReadKey();


            //string[] contents = File.ReadAllLines(@"C:\Users\SpringRain\Desktop\抽象类特点.txt", Encoding.Default);
            //foreach (string item in contents)
            //{
            //    Console.WriteLine(item);
            //}
            //Console.ReadKey();


            //string str = File.ReadAllText("抽象类特点.txt", Encoding.Default);
            //Console.WriteLine(str);
            //Console.ReadKey();

            //File.WriteAllLines(@"C:\Users\SpringRain\Desktop\new.txt", new string[] { "aoe", "ewu" });
            //Console.WriteLine("OK");
            //Console.ReadKey();


            //File.WriteAllText(@"C:\Users\SpringRain\Desktop\new.txt", "张三李四王五赵六");
            //Console.WriteLine("OK");
            //Console.ReadKey();

            //File.AppendAllText(@"C:\Users\SpringRain\Desktop\new.txt", "看我有木有把你覆盖掉");
            //Console.WriteLine("OK");
            //Console.ReadKey();

        }
    }


    public class Person
    {
        public void PersonSayHello()
        {
            Console.WriteLine("我是老师");
        }
    }

    public class Student : Person
    {
        public void StudentSayHello()
        {
            Console.WriteLine("我是学生");
        }
    }

}

    //====== List泛型集合
    using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _02_List泛型集合
{
    class Program
    {
        static void Main(string[] args)
        {
            //创建泛型集合对象
            //List<int> list = new List<int>();
            //list.Add(1);
            //list.Add(2);
            //list.Add(3);

            //list.AddRange(new int[] { 1, 2, 3, 4, 5, 6 });
            //list.AddRange(list);

            //List泛型集合可以转换为数组
            //int[] nums = list.ToArray();

            //List<string> listStr = new List<string>();

            //string[] str = listStr.ToArray();


            //char[] chs = new char[] { 'c', 'b', 'a' };
            //List<char> listChar = chs.ToList();
            //for (int i = 0; i < listChar.Count; i++)
            //{
            //    Console.WriteLine(listChar[i]);
            //}

            ////   List<int> listTwo = nums.ToList();


            //for (int i = 0; i < list.Count; i++)
            //{
            //    Console.WriteLine(list[i]);
            //}
            Console.ReadKey();
        }
    }
}

    //====== 装箱和拆箱
    using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _03_装箱和拆箱
{
    class Program
    {
        static void Main(string[] args)
        {
            //int n = 10;
            //object o = n;//装箱
            //int nn = (int)o;//拆箱


            //ArrayList list = new ArrayList();
            //List<int> list = new List<int>();
            ////这个循环发生了100万次装箱操作
            //Stopwatch sw = new Stopwatch();
            ////00:00:02.4370587
            ////00:00:00.2857600
            //sw.Start();
            //for (int i = 0; i < 10000000; i++)
            //{
            //    list.Add(i);
            //}
            //sw.Stop();
            //Console.WriteLine(sw.Elapsed);
            //Console.ReadKey();


            //这个地方没有发生任意类型的装箱或者拆箱
            //string str = "123";
            //int n = Convert.ToInt32(str);


            int n = 10;
            IComparable i = n;//装箱

            //发生
        }
    }
}

    //====== Dictionary
    using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _04Dictionary
{
    class Program
    {
        static void Main(string[] args)
        {
            Dictionary<int, string> dic = new Dictionary<int, string>();
            dic.Add(1, "张三");
            dic.Add(2, "李四");
            dic.Add(3, "王五");
            dic[1] = "新来的";
            foreach (KeyValuePair<int, string> kv in dic)
            {
                Console.WriteLine("{0}---{1}", kv.Key, kv.Value);
            }

            //foreach (var item in dic.Keys)
            //{
            //    Console.WriteLine("{0}---{1}",item,dic[item]);
            //}
            Console.ReadKey();
        }
    }
}

    //====== 泛型集合的练习
    using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _05泛型集合的练习
{
    class Program
    {
        static void Main(string[] args)
        {
            //将一个数组中的奇数放到一个集合中,再将偶数放到另一个集合中
            //最终将两个集合合并为一个集合,并且奇数显示在左边 偶数显示在右边。

            //int[] nums = { 1, 2, 3, 4, 5, 6, 7, 8, 9 };
            //List<int> listOu = new List<int>();
            //List<int> listJi = new List<int>();
            //for (int i = 0; i < nums.Length; i++)
            //{
            //    if (nums[i] % 2 == 0)
            //    {
            //        listOu.Add(nums[i]);
            //    }
            //    else
            //    {
            //        listJi.Add(nums[i]);
            //    }
            //}


            ////listOu.AddRange(listJi);
            ////foreach (int item in listOu)
            ////{
            ////    Console.Write(item+"  ");
            ////}


            //listJi.AddRange(listOu);
            //foreach (int item in listJi)
            //{
            //    Console.Write(item+"  ");
            //}
            //Console.ReadKey();
            ////List<int> listSum = new List<int>();
            ////listSum.AddRange(listOu);
            ////listSum.AddRange(listJi);

            //提手用户输入一个字符串,通过foreach循环将用户输入的字符串赋值给一个字符数组

            //Console.WriteLine("请输入一个字符串");
            //string input = Console.ReadLine();
            //char[] chs = new char[input.Length];
            //int i = 0;
            //foreach (var item in input)
            //{
            //    chs[i] = item;
            //    i++;
            //}

            //foreach (var item in chs)
            //{
            //    Console.WriteLine(item);
            //}
            //Console.ReadKey();

            //统计 Welcome to china中每个字符出现的次数 不考虑大小写

            string str = "Welcome to China";
            //字符 ------->出现的次数
            //键---------->值
            Dictionary<char, int> dic = new Dictionary<char, int>();
            for (int i = 0; i < str.Length; i++)
            {
                if (str[i] == ' ')
                {
                    continue;
                }
                //如果dic已经包含了当前循环到的这个键 
                if (dic.ContainsKey(str[i]))
                {
                    //值再次加1
                    dic[str[i]]++;
                }
                else//这个字符在集合当中是第一次出现
                {
                    dic[str[i]] = 1;
                }
            }

            foreach (KeyValuePair<char, int> kv in dic)
            {
                Console.WriteLine("字母{0}出现了{1}次", kv.Key, kv.Value);
            }
            Console.ReadKey();

            //w  1


        }
    }
}

    //====== 文件流
    using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _06文件流
{
    class Program
    {
        static void Main(string[] args)
        {

            //使用FileStream来读取数据
            FileStream fsRead = new FileStream(@"C:\Users\SpringRain\Desktop\new.txt", FileMode.OpenOrCreate, FileAccess.Read);
            byte[] buffer = new byte[1024 * 1024 * 5];
            //3.8M  5M
            //返回本次实际读取到的有效字节数
            int r = fsRead.Read(buffer, 0, buffer.Length);
            //将字节数组中每一个元素按照指定的编码格式解码成字符串
            string s = Encoding.UTF8.GetString(buffer, 0, r);
            //关闭流
            fsRead.Close();
            //释放流所占用的资源
            fsRead.Dispose();
            Console.WriteLine(s);
            Console.ReadKey();



            //使用FileStream来写入数据
            //using (FileStream fsWrite = new FileStream(@"C:\Users\SpringRain\Desktop\new.txt", FileMode.OpenOrCreate, FileAccess.Write))
            //{
            //    string str = "看我游牧又把你覆盖掉";
            //    byte[] buffer = Encoding.UTF8.GetBytes(str);
            //    fsWrite.Write(buffer, 0, buffer.Length);
            //}
            //Console.WriteLine("写入OK");
            //Console.ReadKey();
        }
    }
}

    //======  使用文件流来实现多媒体文件的复制
    using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;

namespace _07使用文件流来实现多媒体文件的复制
{
    class Program
    {
        static void Main(string[] args)
        {
            //思路:就是先将要复制的多媒体文件读取出来,然后再写入到你指定的位置
            string source = @"C:\Users\SpringRain\Desktop\1、复习.wmv";
            string target = @"C:\Users\SpringRain\Desktop\new.wmv";
            CopyFile(source, target);
            Console.WriteLine("复制成功");
            Console.ReadKey();
        }

        public static void CopyFile(string soucre, string target)
        {
            //1、我们创建一个负责读取的流
            using (FileStream fsRead = new FileStream(soucre, FileMode.Open, FileAccess.Read))
            {
                //2、创建一个负责写入的流
                using (FileStream fsWrite = new FileStream(target, FileMode.OpenOrCreate, FileAccess.Write))
                {
                    byte[] buffer = new byte[1024 * 1024 * 5];
                    //因为文件可能会比较大,所以我们在读取的时候 应该通过一个循环去读取
                    while (true)
                    {
                        //返回本次读取实际读取到的字节数
                        int r = fsRead.Read(buffer, 0, buffer.Length);
                        //如果返回一个0,也就意味什么都没有读取到,读取完了
                        if (r == 0)
                        {
                            break;
                        }
                        fsWrite.Write(buffer, 0, r);
                    }


                }
            }
        }


    }
}

    //====== StreamReader和StreamWriter
    using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
namespace _08StreamReader和StreamWriter
{
    class Program
    {
        static void Main(string[] args)
        {
            //使用StreamReader来读取一个文本文件
            //using (StreamReader sr = new StreamReader(@"C:\Users\SpringRain\Desktop\抽象类特点.txt",Encoding.Default))
            //{
            //    while (!sr.EndOfStream)
            //    {
            //        Console.WriteLine(sr.ReadLine());
            //    }
            //}


            //使用StreamWriter来写入一个文本文件
            using (StreamWriter sw = new StreamWriter(@"C:\Users\SpringRain\Desktop\newnew.txt", true))
            {
                sw.Write("看我有木有把你覆盖掉");
            }
            Console.WriteLine("OK");
            Console.ReadKey();
        }
    }
}

    //====== 多态
    using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _09多态
{
    class Program
    {
        static void Main(string[] args)
        {
            //概念:让一个对象能够表现出多种的状态(类型)
            //实现多态的3种手段:1、虚方法 2、抽象类 3、接口

            Chinese cn1 = new Chinese("韩梅梅");
            Chinese cn2 = new Chinese("李雷");
            Japanese j1 = new Japanese("树下君");
            Japanese j2 = new Japanese("井边子");
            Korea k1 = new Korea("金秀贤");
            Korea k2 = new Korea("金贤秀");
            American a1 = new American("科比布莱恩特");
            American a2 = new American("奥尼尔");
            Person[] pers = { cn1, cn2, j1, j2, k1, k2, a1, a2, new English("格林"), new English("玛利亚") };

            for (int i = 0; i < pers.Length; i++)
            {
                //if (pers[i] is Chinese)
                //{
                //    ((Chinese)pers[i]).SayHello();
                //}
                //else if (pers[i] is Japanese)
                //{
                //    ((Japanese)pers[i]).SayHello();
                //}
                //else if (pers[i] is Korea)
                //{
                //    ((Korea)pers[i]).SayHello();
                //}
                //else
                //{
                //    ((American)pers[i]).SayHello();
                //}


                pers[i].SayHello();
            }
            Console.ReadKey();
        }
    }

    public class Person
    {
        private string _name;
        public string Name
        {
            get { return _name; }
            set { _name = value; }
        }

        public Person(string name)
        {
            this.Name = name;
        }
        public virtual void SayHello()
        {
            Console.WriteLine("我是人类");
        }

    }

    public class Chinese : Person
    {
        public Chinese(string name)
            : base(name)
        {

        }

        public override void SayHello()
        {
            Console.WriteLine("我是中国人,我叫{0}", this.Name);
        }
    }
    public class Japanese : Person
    {
        public Japanese(string name)
            : base(name)
        { }

        public override void SayHello()
        {
            Console.WriteLine("我是脚盆国人,我叫{0}", this.Name);
        }
    }
    public class Korea : Person
    {
        public Korea(string name)
            : base(name)
        {

        }


        public override void SayHello()
        {
            Console.WriteLine("我是棒之思密达,我叫{0}", this.Name);
        }
    }
    public class American : Person
    {
        public American(string name)
            : base(name)
        {

        }

        public override void SayHello()
        {
            Console.WriteLine("我叫{0},我是米国人", this.Name);
        }
    }


    public class English : Person
    {
        public English(string name)
            : base(name)
        { }

        public override void SayHello()
        {
            Console.WriteLine("我是英国人");
        }
    }

}

    //====== 多态练习
    using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _10多态练习
{
    class Program
    {
        static void Main(string[] args)
        {
            //真的鸭子嘎嘎叫 木头鸭子吱吱叫 橡皮鸭子唧唧叫
            //RealDuck rd = new RealDuck();
            //rd.Bark();
            //MuDuck md = new MuDuck();
            //md.Bark();
            //XPDuck xd = new XPDuck();
            //xd.Bark();
            //Console.ReadKey();

            //RealDuck rd = new RealDuck();
            //MuDuck md = new MuDuck();
            //XPDuck xd = new XPDuck();
            //RealDuck[] ducks = { rd, md, xd };
            //for (int i = 0; i < ducks.Length; i++)
            //{
            //    ducks[i].Bark();
            //}
            //Console.ReadKey();


            //经理十一点打卡 员工9点打卡 程序猿不打卡
            //Employee emp = new Employee();
            //Manager mg = new Manager();
            //Programmer pm = new Programmer();
            //Employee[] emps = { emp, mg, pm };
            //for (int i = 0; i < emps.Length; i++)
            //{
            //    emps[i].DaKa();
            //}
            //Console.ReadKey();



            //狗狗会叫 猫咪也会叫

        }
    }

    public class Animal
    {
        public void Bark()
        {

        }
    }


    public class Employee
    {
        public virtual void DaKa()
        {
            Console.WriteLine("九点打卡");
        }
    }

    public class Manager : Employee
    {
        public override void DaKa()
        {
            Console.WriteLine("经理11点打卡");
        }
    }

    public class Programmer : Employee
    {
        public override void DaKa()
        {
            Console.WriteLine("程序猿不打卡");
        }
    }





    public class RealDuck
    {
        public virtual void Bark()
        {
            Console.WriteLine("真的鸭子嘎嘎叫");
        }
    }

    public class MuDuck : RealDuck
    {
        public override void Bark()
        {
            Console.WriteLine("木头鸭子吱吱叫");
        }
    }

    public class XPDuck : RealDuck
    {
        public override void Bark()
        {
            Console.WriteLine("橡皮鸭子唧唧叫");
        }
    }
}

    //====== 抽象类
    using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _11_抽象类
{
    class Program
    {
        static void Main(string[] args)
        {
            //狗狗会叫 猫咪会叫

            Animal a = new Cat();//new Dog();
            a.Bark();

            Console.ReadKey();
        }
    }

    public abstract class Animal
    {

        public virtual void T()
        {
            Console.WriteLine("动物有声明");
        }

        private int _age;

        public int Age
        {
            get { return _age; }
            set { _age = value; }
        }

        public Animal(int age)
        {
            this.Age = age;
        }
        public abstract void Bark();
        public abstract string Name
        {
            get;
            set;
        }

        //   public abstract string TestString(string name);


        public Animal()
        {

        }
        //public void Test()
        //{ 
        //    //空实现
        //}
    }


    public abstract class Test : Animal
    {

    }

    public class Dog : Animal
    {
        // public abstract void Test();


        public override void Bark()
        {
            Console.WriteLine("狗狗旺旺的叫");
        }

        public override string Name
        {
            get
            {
                throw new NotImplementedException();
            }
            set
            {
                throw new NotImplementedException();
            }
        }

        //public override string TestString(string name)
        //{
        //    //throw new NotImplementedException();
        //}
    }

    public class Cat : Animal
    {
        public override void Bark()
        {
            Console.WriteLine("猫咪喵喵的叫");
        }

        public override string Name
        {
            get
            {
                throw new NotImplementedException();
            }
            set
            {
                throw new NotImplementedException();
            }
        }
    }
}

    //====== 抽象类
    using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _12_抽象类
{
    class Program
    {
        static void Main(string[] args)
        {
            //使用多态求矩形的面积和周长以及圆形的面积和周长
            Shape shape = new Square(5, 6); //new Circle(5);
            double area = shape.GetArea();
            double perimeter = shape.GetPerimeter();
            Console.WriteLine("这个形状的面积是{0},周长是{1}", area, perimeter);
            Console.ReadKey();

        }
    }

    public abstract class Shape
    {
        public abstract double GetArea();
        public abstract double GetPerimeter();
    }
    public class Circle : Shape
    {

        private double _r;
        public double R
        {
            get { return _r; }
            set { _r = value; }
        }

        public Circle(double r)
        {
            this.R = r;
        }
        public override double GetArea()
        {
            return Math.PI * this.R * this.R;
        }

        public override double GetPerimeter()
        {
            return 2 * Math.PI * this.R;
        }
    }
    public class Square : Shape
    {
        private double _height;

        public double Height
        {
            get { return _height; }
            set { _height = value; }
        }

        private double _width;

        public double Width
        {
            get { return _width; }
            set { _width = value; }
        }

        public Square(double height, double width)
        {
            this.Height = height;
            this.Width = width;
        }

        public override double GetArea()
        {
            return this.Height * this.Width;
        }

        public override double GetPerimeter()
        {
            return (this.Height + this.Width) * 2;
        }
    }

}

    //====== 电脑_移动硬盘_U盘_MP3
    using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _13_电脑_移动硬盘_U盘_MP3
{
    class Program
    {
        static void Main(string[] args)
        {
            //用多态来实现 将 移动硬盘或者U盘或者MP3插到电脑上进行读写数据

            //MobileDisk md = new MobileDisk();
            //UDisk u = new UDisk();
            //Mp3 mp3 = new Mp3();
            //Computer cpu = new Computer();
            //cpu.CpuRead(u);
            //cpu.CpuWrite(u);
            //Console.ReadKey();

            MobileStorage ms = new UDisk();//new Mp3();//new MobileDisk();//new UDisk();
            Computer cpu = new Computer();
            cpu.Ms = ms;
            cpu.CpuRead();
            cpu.CpuWrite();
            //Computer cpu = new Computer();
            //cpu.CpuRead(ms);
            //cpu.CpuWrite(ms);
            Console.ReadKey();

        }
    }


    /// <summary>
    /// 抽象的父类
    /// </summary>
    public abstract class MobileStorage
    {
        public abstract void Read();
        public abstract void Write();
    }


    public class MobileDisk : MobileStorage
    {
        public override void Read()
        {
            Console.WriteLine("移动硬盘在读取数据");
        }
        public override void Write()
        {
            Console.WriteLine("移动硬盘在写入数据");
        }
    }
    public class UDisk : MobileStorage
    {
        public override void Read()
        {
            Console.WriteLine("U盘在读取数据");
        }

        public override void Write()
        {
            Console.WriteLine("U盘在写入数据");
        }
    }
    public class Mp3 : MobileStorage
    {
        public override void Read()
        {
            Console.WriteLine("MP3在读取数据");
        }

        public override void Write()
        {
            Console.WriteLine("Mp3在写入数据");
        }

        public void PlayMusic()
        {
            Console.WriteLine("MP3自己可以播放音乐");
        }
    }



    public class Computer
    {
        private MobileStorage _ms;

        public MobileStorage Ms
        {
            get { return _ms; }
            set { _ms = value; }
        }
        public void CpuRead()
        {
            Ms.Read();
        }

        public void CpuWrite()
        {
            Ms.Write();
        }
    }
}

    //====== FileStream

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace FileStream
{
    class Program
    {
        static void Main(string[] args)
        {
            // FileStream   操作字节的
            //1、创建FileStream对象

            FileStream








            //StreamReader和StreamWriter 操作字符的



        }
    }
}

    //====== 复习
    using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
namespace _01复习
{
    class Program
    {
        static void Main(string[] args)
        {
            /*
             泛型集合
             * List<T>
             * Dictionary<T,T>
             * 装箱和拆箱
             * 装箱:将值类型转换为引用类型
             * 拆箱:将引用类型转换为值类型
             * 我们应该尽量避免在代码中发生装箱或者拆箱
             * 文件流
             * FileStream StreamReader和StreamWriter
             * 多态:虚方法、
             * //抽象类、接口
             * 虚方法:
             * 抽象类:
             
             */
            //List<int> list = new List<int>();

            //Dictionary<int, string> dic = new Dictionary<int, string>();
            //dic.Add(1, "张三");
            //dic[2] = "李四";
            //foreach (KeyValuePair<int,string> kv in dic)
            //{
            //    Console.WriteLine("{0}-----{1}",kv.Key,kv.Value);
            //}
            //Console.ReadKey();

            //File  FileStream StreamReader StreamWriter
            //using (FileStream fsRead = new FileStream("0505远程版机器码.txt", FileMode.OpenOrCreate, FileAccess.Read))
            //{
            //    byte[] buffer = new byte[1024 * 1024 * 5];
            //    //本次读取实际读取到的字节数
            //    int r = fsRead.Read(buffer, 0, buffer.Length);

            //    //将字节数组中的每个元素按照我们指定的编码格式解析成字符串
            //    string s = Encoding.Default.GetString(buffer, 0, r);
            //    Console.WriteLine(s);
            //}
            //Console.ReadKey();

            //using (FileStream fsWrite = new FileStream(@"C:\Users\SpringRain\Desktop\new.txt", FileMode.Append, FileAccess.Write))
            //{
            //    string s = "abc";
            //    byte[] buffer=Encoding.UTF8.GetBytes(s);
            //    fsWrite.Write(buffer,0,buffer.Length);
            //}
            //Console.WriteLine("OK");
            //Console.ReadKey();






            //虚方法和抽象类

            //老师可以起立  学生也可以起立  校长也可以起立

            //声明父类去指定子类对象

            Person p = new HeadMaster();//new Teacher();//new Student();
            p.StandUp();
            Console.ReadKey();

        }
    }


    public abstract class Person
    {
        public abstract void StandUp();
    }

    public class Student : Person
    {
        public override void StandUp()
        {
            Console.WriteLine("学生起立,说老师好");
        }
    }


    public class Teacher : Person
    {
        public override void StandUp()
        {
            Console.WriteLine("老师起立,说校长好");
        }
    }

    public class HeadMaster : Person
    {
        public override void StandUp()
        {
            Console.WriteLine("校长起来说领导好");
        }
    }



}

    //======  访问修饰符 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _02访问修饰符
{
    class Program
    {
        static void Main(string[] args)
        {
            Person p = new Person();
        }
    }

    public class Person
    {
        //protected string _name;
        //public int _age;
        //private char _gender;
        //internal int _chinese;
        //protected internal int _math;
    }

    public class Student : Person
    {

    }

    //public class Student:Person
    //{ 

    //}
}

    //====== 简单工厂设计模式
    using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _03简单工厂设计模式
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("请输入您想要的笔记本品牌");
            string brand = Console.ReadLine();
            NoteBook nb = GetNoteBook(brand);
            nb.SayHello();
            Console.ReadKey();
        }


        /// <summary>
        /// 简单工厂的核心 根据用户的输入创建对象赋值给父类
        /// </summary>
        /// <param name="brand"></param>
        /// <returns></returns>
        public static NoteBook GetNoteBook(string brand)
        {
            NoteBook nb = null;
            switch (brand)
            {
                case "Lenovo":
                    nb = new Lenovo();
                    break;
                case "IBM":
                    nb = new IBM();
                    break;
                case "Acer":
                    nb = new Acer();
                    break;
                case "Dell":
                    nb = new Dell();
                    break;
            }
            return nb;
        }
    }

    public abstract class NoteBook
    {
        public abstract void SayHello();
    }

    public class Lenovo : NoteBook
    {
        public override void SayHello()
        {
            Console.WriteLine("我是联想笔记本,你联想也别想");
        }
    }


    public class Acer : NoteBook
    {
        public override void SayHello()
        {
            Console.WriteLine("我是鸿基笔记本");
        }
    }

    public class Dell : NoteBook
    {
        public override void SayHello()
        {
            Console.WriteLine("我是戴尔笔记本");
        }
    }

    public class IBM : NoteBook
    {
        public override void SayHello()
        {
            Console.WriteLine("我是IBM笔记本");
        }
    }
}

    //====== 值类型和引用类型
    using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _04值类型和引用类型
{
    class Program
    {
        static void Main(string[] args)
        {
            //值类型:int double char decimal bool enum struct 
            //引用类型:string 数组  自定义类 集合 object 接口

            //值传递和引用传递
            //int n1 = 10;
            //int n2 = n1;
            //n2 = 20;
            //Console.WriteLine(n1);
            //Console.WriteLine(n2);
            //Console.ReadKey();

            //Person p1 = new Person();
            //p1.Name = "张三";
            //Person p2 = p1;
            //p2.Name = "李四";
            //Console.WriteLine(p1.Name);
            //Console.ReadKey();

            //Person p = new Person();
            //p.Name = "张三";
            //Test(p);
            //Console.WriteLine(p.Name);
            //Console.ReadKey();

            //string s1 = "张三";
            //string s2 = s1;
            //s2 = "李四";
            //Console.WriteLine(s1);
            //Console.WriteLine(s2);
            //Console.ReadKey();

            int number = 10;
            TestTwo(ref number);
            Console.WriteLine(number);
            Console.ReadKey();
        }
        //int n=number;
        public static void TestTwo(ref int n)
        {
            n += 10;
        }

        //Person pp=p;
        public static void Test(Person pp)
        {
            Person p = pp;
            p.Name = "李四";
        }
    }

    public class Person
    {
        private string _name;
        public string Name
        {
            get { return _name; }
            set { _name = value; }
        }
    }
}

    //====== 序列化和反序列化
    using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Runtime.Serialization.Formatters.Binary;
namespace _05序列化和反序列化
{
    class Program
    {
        static void Main(string[] args)
        {
            //要将p这个对象 传输给对方电脑
            //Person p = new Person();
            //p.Name = "张三";
            //p.Age = 19;
            //p.Gender = '男';
            //using (FileStream fsWrite = new FileStream(@"C:\Users\SpringRain\Desktop\111.txt", FileMode.OpenOrCreate, FileAccess.Write))
            //{ 
            //    //开始序列化对象
            //    BinaryFormatter bf = new BinaryFormatter();
            //    bf.Serialize(fsWrite, p);
            //}
            //Console.WriteLine("序列化成功");
            //Console.ReadKey();

            //接收对方发送过来的二进制 反序列化成对象
            Person p;
            using (FileStream fsRead = new FileStream(@"C:\Users\SpringRain\Desktop\111.txt", FileMode.OpenOrCreate, FileAccess.Read))
            {
                BinaryFormatter bf = new BinaryFormatter();
                p = (Person)bf.Deserialize(fsRead);
            }
            Console.WriteLine(p.Name);
            Console.WriteLine(p.Age);
            Console.WriteLine(p.Gender);
            Console.ReadKey();
        }
    }


    [Serializable]
    public class Person
    {
        private string _name;

        public string Name
        {
            get { return _name; }
            set { _name = value; }
        }


        private char _gender;

        public char Gender
        {
            get { return _gender; }
            set { _gender = value; }
        }

        private int _age;

        public int Age
        {
            get { return _age; }
            set { _age = value; }
        }
    }
}

    //====== 部分类
    using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _06部分类
{
    class Program
    {
        static void Main(string[] args)
        {
        }
    }

    public partial class Person
    {
        private string _name;
        public void Test()
        {

        }
    }

    public partial class Person
    {
        public void Test(string name)
        {
            // _name
        }
    }
}

    //====== 密封类
    using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _07密封类
{
    class Program
    {
        static void Main(string[] args)
        {

        }
    }

    public sealed class Person : Test
    {

    }

    public class Test
    {

    }
}

    //====== 重写ToString__方法
    using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _08重写ToString__方法
{
    class Program
    {
        static void Main(string[] args)
        {
            Person p = new Person();
            Console.WriteLine(p.ToString());
            Console.ReadKey();
        }
    }

    public class Person
    {
        public override string ToString()
        {
            return "Hello World";
        }
    }
}

    //====== 接口
    using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _09接口
{
    class Program
    {
        static void Main(string[] args)
        {
            //接口就是一个规范、能力。
        }
    }

    public class Person
    {
        public void CHLSS()
        {
            Console.WriteLine("我是人类,我可以吃喝拉撒睡");
        }
    }
    public class NBAPlayer
    {
        public void KouLan()
        {
            Console.WriteLine("我可以扣篮");
        }
    }

    public class Student : Person, IKouLanable
    {
        public void KouLan()
        {
            Console.WriteLine("我也可以扣篮");
        }
    }


    public interface IKouLanable
    {
        void KouLan();
    }

}

    //====== 接口的语法特征
    using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _10接口的语法特征
{
    class Program
    {
        static void Main(string[] args)
        {

        }
    }

    public interface IFlyable
    {
        //接口中的成员不允许添加访问修饰符 ,默认就是public
        void Fly();
        string Test();
        //不允许写具有方法体的函数

        //   string _name;
        string Name
        {
            get;
            set;
        }

    }
}

    //====== 自动属性和普通属性
    using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _11_自动属性和普通属性
{
    class Program
    {
        static void Main(string[] args)
        {
        }
    }
    public class Person
    {
        private string _name;

        public string Name
        {
            get { return _name; }
            set { _name = value; }
        }

        /// <summary>
        /// 自动属性
        /// </summary>
        public int Age
        {
            get;
            set;
        }
    }
}

    //====== 接口特点
    using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _12接口特点
{
    class Program
    {
        static void Main(string[] args)
        {
            IFlyable fly = new Bird();//new Person();// new IFlyable();
            fly.Fly();
            Console.ReadKey();
        }
    }
    public class Person : IFlyable
    {
        public void Fly()
        {
            Console.WriteLine("人类在飞");
        }
    }


    public class Student
    {
        public void Fly()
        {
            Console.WriteLine("人类在飞");
        }
    }

    public class Bird : IFlyable
    {
        public void Fly()
        {
            Console.WriteLine("鸟在飞");
        }
    }

    public interface IFlyable
    {
        //不允许有访问修饰符 默认为public
        //方法、自动属性
        void Fly();
    }



    public interface M1
    {
        void Test1();
    }

    public interface M2
    {
        void Test2();
    }

    public interface M3
    {
        void Test3();
    }


    public interface SupperInterface : M1, M2, M3
    {

    }

    public class Car : SupperInterface
    {

        public void Test1()
        {
            throw new NotImplementedException();
        }

        public void Test2()
        {
            throw new NotImplementedException();
        }

        public void Test3()
        {
            throw new NotImplementedException();
        }
    }

}

    //====== 接口练习
    using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _13接口练习
{
    class Program
    {
        static void Main(string[] args)
        {
            //麻雀会飞  鹦鹉会飞  鸵鸟不会飞 企鹅不会飞  直升飞机会飞
            //用多态来实现
            //需方法、抽象类、接口


            IFlyable fly = new Plane();//new MaQue();//new YingWu();
            fly.Fly();
            Console.ReadKey();


        }
    }

    public class Bird
    {
        public double Wings
        {
            get;
            set;
        }
        public void EatAndDrink()
        {
            Console.WriteLine("我会吃喝");
        }
    }

    public class MaQue : Bird, IFlyable
    {

        public void Fly()
        {
            Console.WriteLine("麻雀会飞");
        }
    }

    public class YingWu : Bird, IFlyable, ISpeak
    {


        public void Fly()
        {
            Console.WriteLine("鹦鹉会飞");
        }

        public void Speak()
        {
            Console.WriteLine("鹦鹉可以学习人类说话");
        }
    }


    public class TuoBird : Bird
    {

    }

    public class QQ : Bird
    {

    }


    public class Plane : IFlyable
    {
        public void Fly()
        {
            Console.WriteLine("直升飞机转动螺旋桨飞行");
        }
    }



    public interface IFlyable
    {
        void Fly();

    }

    public interface ISpeak
    {
        void Speak();
    }


}

    //====== 显示实现接口
    using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _14_显示实现接口
{
    class Program
    {
        static void Main(string[] args)
        {
            //显示实现接口就是为了解决方法的重名问题
            IFlyable fly = new Bird();
            fly.Fly();
            Bird bird = new Bird();
            bird.Fly();

            Console.ReadKey();
        }
    }


    public class Bird : IFlyable
    {
        public void Fly()
        {
            Console.WriteLine("鸟飞会");
        }
        /// <summary>
        /// 显示实现接口
        /// </summary>
        void IFlyable.Fly()
        {
            Console.WriteLine("我是接口的飞");
        }

    }

    public interface IFlyable
    {
        void Fly();
    }
}

    //====== 总结
    using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _15_总结
{
    class Program
    {
        static void Main(string[] args)
        {
            //什么时候用虚方法来实现多态?
            //什么使用用抽象类来实现多态?
            //什么时候用接口来实现多态?

            //真的鸭子会游泳 木头鸭子不会游泳 橡皮鸭子会游泳

            ISwimming swim = new XPDuck();//new RealDuck();
            swim.Swim();
            Console.ReadKey();
        }
    }

    public class RealDuck : ISwimming
    {

        public void Swim()
        {
            Console.WriteLine("真的鸭子靠翅膀游泳");
        }
    }

    public class MuDuck
    {

    }

    public class XPDuck : ISwimming
    {

        public void Swim()
        {
            Console.WriteLine("橡皮鸭子飘着游泳");
        }
    }

    public interface ISwimming
    {
        void Swim();
    }
}

    //====== 超市收银系统
    //====== GUID

    //====== 
    //====== 
    //====== 
    //======  
    //====== 
    //====== 
    //====== 
    //====== 
    //====== 
    //====== 
    //====== 
    //====== 
    //======   
    //====== 
    //====== 
    //====== 
    //====== 
    //====== 
    //====== 
    //====== 
    //====== 
    //====== 



}
}
}
分类:

发表评论