0

i am new to c# , and i am trying to write a piece of code that is equivalent to code written in java below.

i need an input dialogue that asksthe user to enter his choice, sadly my attempts ended in both run time and compile time errors:)

i would apperciate your help

this is the code in java , which i am trying to implement in c#

  do{

    String name = JOptionPane.showInputDialog(null, "PLEASE ENTER YOUR CHOICE OF    SQUARE NUMBER");

    choice = Integer.parseInt(name);
    choice --;
    }while(TicTac[choice]!=' ');

Thank You:)

Marwan Tushyeh
  • 1,505
  • 4
  • 24
  • 47
  • What are you using? WinForms, WPF or something else? And maybe it would be better if you showed us your code. Or are you going to ask new question for each method you need to implement? – svick Oct 25 '11 at 00:49

2 Answers2

2

Add a reference to Microsoft.VisualBasic.dll.

Call Microsoft.VisualBasic.Interaction.InputBox(...).

Daniel A. White
  • 187,200
  • 47
  • 362
  • 445
0

@Daniel White is correct. C# doesn't have that dialog. You can load the VB.Net equivolent using his example. See here: What is the C# version of VB.net's InputDialog? for more.

For the rest of your code:

while (TicTac[choice] != ' ')
{
     String name = Microsoft.VisualBasic.Interaction.InputBox(null, "PLEASE ENTER YOUR CHOICE OF SQUARE NUMBER");

    choice = Integer.parseInt(name);
    choice --;
}

Thats a quick copy/paste but should get you close

Community
  • 1
  • 1
Rob Allen
  • 17,381
  • 5
  • 52
  • 70