请帮帮我,我无法输出正确的结果 [英] Please Help me I am unable to output the correct results

查看:55
本文介绍了请帮帮我,我无法输出正确的结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

美好的一天每个人



我需要你的帮助,我正在编写一个程序,它会根据

userinput返回某个结果然而,我测试了它,我继续获得第一个案例的结果

第一和第二个案例。



Good Day Everyone

I need your help, I am writing a program that will return a certain result based on a
userinput, however I tested it and I keep getting the first case's result for both
first and second case.

private void Button_Click_1(object sender, RoutedEventArgs e)
  {
      SpiderNames myspiders;
      string userInputTextBox = "";


      if (Enum.TryParse<SpiderNames>(userInputTextBox, true, out myspiders));
      {

      switch (myspiders)
      {
          case SpiderNames.Violen:

              string Violen = File.ReadAllText(@"C:\Users\Documents\Violen.txt");
              outPutTextBox.Text = Violen;

              break;

          case SpiderNames.Sacspider:

              string Sacspider = File.ReadAllText(@"C:\Users\Documents\Sacspider.txt");
              outPutTextBox.Text = Sacspider;

              break;
          case SpiderNames.Daddylonglegs:
              break;
          default:
              break;

推荐答案

userInputTextBox 设置为空字符串,因此您的函数将解析空字符串。相反,将文本框的值放在那里,如下所示:

You set userInputTextBox to an empty string, so your function will parse an empty string. Instead, put the value of a text box in there, like this:
userInputTextBox = yourTextBox.Text;


这篇关于请帮帮我,我无法输出正确的结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆