开发者

getting user input in c#

开发者 https://www.devze.com 2022-12-26 05:00 出处:网络
is there a way to get user input like an inputbox i开发者_JS百科n c#? i would like a window to pop up to ask a user to enter a stringC# itself doesn\'t have such a feature, assuming you\'re using Winf

is there a way to get user input like an inputbox i开发者_JS百科n c#? i would like a window to pop up to ask a user to enter a string


C# itself doesn't have such a feature, assuming you're using Winforms, but you can steal one from VB.NET's default libraries (from the Microsoft.VisualBasic namespace):

using Microsoft.VisualBasic;

class Program
{
    static void Main()
    {
       var response = Interaction.InputBox("Enter some text!", "Title", "Default text");
    }
}

See MSDN for more info.

You could also create your own window using WinForms (or WPF) if you need it to do something more specific.

0

精彩评论

暂无评论...
验证码 换一张
取 消