Home >Backend Development >C++ >How to Create a C# Equivalent of VB.NET's InputBox?
C# Equivalent of VB.NET's InputBox
VB.NET's InputBox, used to display a modal pop-up window for user input, has a C# counterpart.
C# Implementation
The C# version of InputBox requires adding a reference to the Microsoft.VisualBasic assembly. Once the reference is added, you can access the InputBox function from the Microsoft.VisualBasic.Interaction namespace. Here is the C# code to achieve the same functionality:
using Microsoft.VisualBasic; namespace InputBoxExample { class Program { static void Main(string[] args) { string input = Interaction.InputBox("Enter your name:", "Input Box Example", "John Doe", 100, 100); Console.WriteLine($"User entered: {input}"); } } }
In this example:
Note: The only mandatory argument is the first one, which is the prompt displayed to the user.
The above is the detailed content of How to Create a C# Equivalent of VB.NET's InputBox?. For more information, please follow other related articles on the PHP Chinese website!