Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# do while循环(计算器)net.framework出现问题_C#_.net - Fatal编程技术网

C# do while循环(计算器)net.framework出现问题

C# do while循环(计算器)net.framework出现问题,c#,.net,C#,.net,我的问题是:即使我输入+,-,*,/,我仍然卡在do-while循环中(选择运算符) using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Rechner_mit_Loop { class Program { static void Main(string[] arg

我的问题是:即使我输入+,-,*,/,我仍然卡在do-while循环中(选择运算符)

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

namespace Rechner_mit_Loop
{
    class Program
    {
        static void Main(string[] args)
        {
            bool b_Konv1;
            bool b_Konv2;
            bool b_Konv3;

            string s_Zahl1;
            string s_Zahl2;
            string s_Zahl3;
            string s_OP;
            string s_Ende;

            int i_Zahl1;
            int i_Zahl2;
            int i_Zahl3;
            int i_ZahlE;
            int i_ZahlD;

            do
            {
                do
                {
                    Console.WriteLine("Erste Zahl eingeben!");
                    s_Zahl1 = Console.ReadLine();
                    b_Konv1 = int.TryParse(s_Zahl1, out i_Zahl1);
                }   while (!b_Konv1);

                do
                {
                    Console.WriteLine("Operator wählen!");
                    s_OP = Console.ReadLine();
                }   while (s_OP != "+" || s_OP != "-" || s_OP != "*" || s_OP != "/");

                if  (s_OP == "Hallo")
                {
                    do
                    {
                        do
                        {
                            Console.WriteLine("Zweite Zahl eingeben!");
                            s_Zahl2 = Console.ReadLine();
                            b_Konv2 = int.TryParse(s_Zahl2, out i_Zahl2);
                        }   while (!b_Konv2);

                    } while (i_Zahl2 == 0);

                    i_ZahlD = i_Zahl1 / i_Zahl2;
                    Console.WriteLine(i_Zahl1 + "/" + i_Zahl2 + "=" + i_ZahlD);
                }
                else
                {
                    do
                    {
                        Console.WriteLine("Zweite Zahl eingeben!");
                        s_Zahl3 = Console.ReadLine();
                        b_Konv3 = int.TryParse(s_Zahl3, out i_Zahl3);
                    }   while (!b_Konv3);

                    switch (s_OP)
                    {
                        case "Addition":
                            Console.WriteLine("Addition");
                            i_ZahlE = i_Zahl1 + i_Zahl3;
                            Console.WriteLine(i_Zahl1 + "+" + i_Zahl3 + "=" + i_ZahlE);
                            break;

                        case "-":
                            Console.WriteLine("Subtraktion");
                            i_ZahlE = i_Zahl1 - i_Zahl3;
                            Console.WriteLine(i_Zahl1 + "-" + i_Zahl3 + "=" + i_ZahlE);
                            break;

                        case "*":
                            Console.WriteLine("Multiplikation");
                            i_ZahlE = i_Zahl1 * i_Zahl3;
                            Console.WriteLine(i_Zahl1 + "*" + i_Zahl3 + "=" + i_ZahlE);
                            break;
                    }                    
                }
                Console.WriteLine("ENDE eingeben um Rechner zu beenden!");
                s_Ende = Console.ReadLine();
            } while (s_Ende != "ENDE");


            Console.ReadLine();
        }
    }
}

非常简单,只需执行
while(s_OP!=“+”&&s_OP!=“-”&&s_OP!=“*”&&s_OP!=“/”

否则它将始终为真,因为您的s_OP不能同时是+、-、*和/或