Sunday, October 23, 2011

C# debugging–an input message box

C# doesn’t have a convenient message-box that you can use for gathering user-input (which is especially useful when you are writing code for the purpose of debugging). VisualBasic has just such a form, which you can use in C#.

Add a reference to Microsoft.VisualBasic.dll

Use the following code:

Microsoft.VisualBasic.Interaction.InputBox("What would you like to do today?","To be or not to be","that is the question…");

Which creates a dialog like so:
image

MSDN: http://msdn.microsoft.com/en-us/library/microsoft.visualbasic.interaction.inputbox.aspx

No comments:

Post a Comment

Remember, if you want me to respond to your comment, then you need to use a Google/OpenID account to leave the comment.