怎么运行失败呀

来源:3-6 C#中多重if结构

慕盖茨9525359

2017-09-18 20:51

using System;

using System.Collections.Generic;

using System.Text;


namespace Test

{

    class Program

    {

        static void Main(string[] args)

        {

            string job = "科员";

            if (job == "局长")

            {

                Console.WriteLine("发双黄月饼");

            }

            else if (job == "处长")

            {

                Console.WriteLine("发蛋黄月饼");

            }

           else if(job=='科长') //请输入

            {

                Console.WriteLine("发枣泥月饼");

            }

           

           else//请输入

            {

                Console.WriteLine("发五仁月饼");

            }

        }

    }

}


写回答 关注

3回答

  • qq_RR_15
    2018-05-03 20:27:24

    using System;

    using System.Collections.Generic;

    using System.Text;


    namespace Test

    {

        class Program

        {

            static void Main(string[] args)

            {

                string job = "科员";

                if (job == "局长")

                {

                    Console.WriteLine("发双黄月饼");

                }

                else if (job == "处长")

                {

                    Console.WriteLine("发蛋黄月饼");

                }

                else if (job == "科员")//请输入

                {

                    Console.WriteLine("发枣泥月饼");

                }

                else//请输入

                {

                    Console.WriteLine("发五仁月饼");

                }

            }

        }

    }


  • 慕无忌7508023
    2017-11-24 19:34:33

    注意else if(job=='科长') 这里因该用字符串类型而不是字符型因为输入的汉字数目已经超过了一个人

  • 小孩子_0001
    2017-09-18 21:07:18

     else if(job=='科长') //请输入 

     else if(job=="科长") 你的符号打错了是“”不是''

C#开发轻松入门

本门课程是C#语言的入门教程,将带你轻松入门.NET开发

255675 学习 · 1524 问题

查看课程

相似问题