<small id='KmR18'></small><noframes id='KmR18'>

  • <tfoot id='KmR18'></tfoot>
  • <i id='KmR18'><tr id='KmR18'><dt id='KmR18'><q id='KmR18'><span id='KmR18'><b id='KmR18'><form id='KmR18'><ins id='KmR18'></ins><ul id='KmR18'></ul><sub id='KmR18'></sub></form><legend id='KmR18'></legend><bdo id='KmR18'><pre id='KmR18'><center id='KmR18'></center></pre></bdo></b><th id='KmR18'></th></span></q></dt></tr></i><div id='KmR18'><tfoot id='KmR18'></tfoot><dl id='KmR18'><fieldset id='KmR18'></fieldset></dl></div>

        <bdo id='KmR18'></bdo><ul id='KmR18'></ul>

      1. <legend id='KmR18'><style id='KmR18'><dir id='KmR18'><q id='KmR18'></q></dir></style></legend>

      2. 读取双重类型的用户输入

        时间:2023-08-27
      3. <legend id='74grs'><style id='74grs'><dir id='74grs'><q id='74grs'></q></dir></style></legend>

        <small id='74grs'></small><noframes id='74grs'>

            <bdo id='74grs'></bdo><ul id='74grs'></ul>
                <i id='74grs'><tr id='74grs'><dt id='74grs'><q id='74grs'><span id='74grs'><b id='74grs'><form id='74grs'><ins id='74grs'></ins><ul id='74grs'></ul><sub id='74grs'></sub></form><legend id='74grs'></legend><bdo id='74grs'><pre id='74grs'><center id='74grs'></center></pre></bdo></b><th id='74grs'></th></span></q></dt></tr></i><div id='74grs'><tfoot id='74grs'></tfoot><dl id='74grs'><fieldset id='74grs'></fieldset></dl></div>

                  <tbody id='74grs'></tbody>

                  <tfoot id='74grs'></tfoot>

                  本文介绍了读取双重类型的用户输入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我发现在其他地方使用循环回答了这个问题,但我不确定是否真的有一个我没有找到的函数可以让这更容易,或者这是否可能(在我看来)消极的一面到 C#.

                  I have found this answered in other places using loops, but I wasn't sure if there is actually a function that I'm not finding that makes this easier, or if this is a possible (in my opinion) negative side to C#.

                  我正在尝试从这样的用户输入中读取双精度:

                  I'm trying to read in a double from user input like this:

                  Console.WriteLine("Please input your total salary: ") // i input 100
                  double totalSalary = Console.Read(); //reads in the 1, changes to 49.
                  

                  我在这方面找到了其他几个帖子,他们都有不同的答案,而且提出的问题也不完全相同.如果我只想读取用户输入,那么最好的方法是什么?

                  I've found a couple other posts on this, and they all have different answers, and the questions asked aren't exactly the same either. If i just want the user input read in, what is the best way to do that?

                  推荐答案

                  你必须检查整个事情.因为 Console.Read() 返回一个整数.

                  You'll have to check the entire thing on it's way in.. as Console.Read() returns an integer.

                  double totalSalary;
                  if (!double.TryParse(Console.ReadLine(), out totalSalary)) {
                      // .. error with input
                  }
                  // .. totalSalary is okay here.
                  

                  这篇关于读取双重类型的用户输入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:用 C# 中的每个新线程打开一个新控制台? 下一篇:DotNetFiddle 和 Console.ReadLine 出现问题,在按下 EN

                  相关文章

                  最新文章

                  • <bdo id='T4y7r'></bdo><ul id='T4y7r'></ul>
                  <i id='T4y7r'><tr id='T4y7r'><dt id='T4y7r'><q id='T4y7r'><span id='T4y7r'><b id='T4y7r'><form id='T4y7r'><ins id='T4y7r'></ins><ul id='T4y7r'></ul><sub id='T4y7r'></sub></form><legend id='T4y7r'></legend><bdo id='T4y7r'><pre id='T4y7r'><center id='T4y7r'></center></pre></bdo></b><th id='T4y7r'></th></span></q></dt></tr></i><div id='T4y7r'><tfoot id='T4y7r'></tfoot><dl id='T4y7r'><fieldset id='T4y7r'></fieldset></dl></div>
                    <legend id='T4y7r'><style id='T4y7r'><dir id='T4y7r'><q id='T4y7r'></q></dir></style></legend>

                      <small id='T4y7r'></small><noframes id='T4y7r'>

                      <tfoot id='T4y7r'></tfoot>