using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Square.sln
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
DialogResult dr;
string i;
double num;
do
{
i = Microsoft.VisualBasic.Interation.InputBox
("請輸入數值:", "求平方");
num = Convert.ToDouble(i);
dr = MessageBox.Show(i + "的平方等於" + (num * num).ToString() +
"\n是否繼續?", "平方", MessageBoxButtons.YesNo);
} while (dr == DialogResult.Yes);
Application.Exit();
}
}
}
這裡紅線的Interation錯誤是指不要用還是不能用還是其他意思,只有查到避免名稱衝突這樣類似的答案,但還是不明白
需要引用 Microsoft.VisualBasic
https://www.delftstack.com/zh-tw/howto/csharp/create-an-input-dialog-box-in-csharp/