简体   繁体   English

如何让我的控制台窗口停止让我在Visual Studio中输入?

[英]How do I make my console window stop making me type enter in Visual Studio?

I have a simple application to practice C# but my console window makes me type enter instead of showing the whole result at once and I don't think that there is anything wrong with the code. 我有一个简单的应用程序来练习C#,但我的控制台窗口让我输入enter而不是一次显示整个结果,我不认为代码有任何问题。 I have pasted my code here anyways. 无论如何我在这里粘贴了我的代码。 I just don't want to have to type enter every time I want to see something in the console window. 我只是不想每次想要在控制台窗口中看到某些内容时输入enter。 How do I change this? 我该如何改变?

namespace CallingMethods
{
    class Program
    {
        static void Main(string[] args)
        {
            NameGame("John", "Smith");
            int myNumber = NumberGame(1234);
            Console.WriteLine(myNumber); Console.ReadLine();
        }

        public static void NameGame(string firstName, string lastName)
        {
            char[] firstNameArray = firstName.ToCharArray();
            Array.Reverse(firstNameArray);

            char[] lastNameArray = lastName.ToCharArray();
            Array.Reverse(lastNameArray);

            string result = " ";

            foreach (char item in firstNameArray)
            {
                result+=item;
            }

            result += " ";

            foreach (char item in lastNameArray)
            {
                result += item;
            }
            Console.WriteLine(result); Console.ReadLine();
        }

        private static int NumberGame(int v)
        {
            return (v*2) * 100;
        }





}

} }

You have Console.ReadLine(); 你有Console.ReadLine(); at the end of NameGame() and the result is printed after this call. NameGame()的末尾,结果在此调用后打印。 Due to this you need to enter a line before it gives you result. 因此,您需要在给出结果之前输入一行。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何创建一个允许我输入LINQ表达式的控制台应用程序,我的程序将执行它们? - How can I make a console application that lets me enter LINQ expressions and my program will execute them? 如何在Visual Studio 2015输出窗口中阻止C#编译器输出? - How do I stop the C# compiler output from wrapping in the Visual Studio 2015 output window? 当我输入“new {”时,如何阻止Visual Studio插入“object” - How do I stop Visual Studio from inserting “object” when I type “new {” 如何在Visual Studio的属性窗口中使类型可编辑? - How to make a type editable in properties window in visual studio? 如何阻止Visual Studio在UserControl中生成Setter调用? - How Do I Stop Visual Studio from Generating Setter Calls in my UserControl? 如何使用户必须输入一个窗口? - How do I make a window compulsory for the user to enter some information? 如何让Visual Studio的测试窗口使用我的ITestContainerDiscoverer? - How do I get Visual Studio's test window to use my ITestContainerDiscoverer? 在带有C#的Visual Studio中,如何在键入时自动显示(),例如.Focus()? - In Visual Studio with C#, how do I make the () appear automatically when I type, such as .Focus()? Visual Studio 2013 - 如何在控制台中查看输出? - Visual Studio 2013 - How do I view output in the console? 如何在Visual Studio 2010中停止自动轮廓扩展? - How do I stop Auto Outline Expansion in Visual Studio 2010?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM