Error CS0106 The modifier 'public' is not valid for this item Line 30
Error CS8370 Feature 'static local functions' is not available in C# 7.3.
Please use language version 8.0 or greater. Line 30
Error CS0136 A local or parameter named 'value' cannot be
declared in this scope because that name is
used in an enclosing local scope to define
a local or parameter. Line 30
///////////////////////////////////////////////////////////////////////////////
Error CS8370 Feature 'static local functions' is not available in C# 7.3.
Please use language version 8.0 or greater. Line 30
Error CS0136 A local or parameter named 'value' cannot be
declared in this scope because that name is
used in an enclosing local scope to define
a local or parameter. Line 30
///////////////////////////////////////////////////////////////////////////////
Input Dialog Box:
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 Input_Dialog_Box
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
string value = "";
if (InputBox("Dialog Box", "What is your name?", ref value) == DialogResult.OK)
{
labelResponseInput.Visible = true;
labelResponseInput.Text = "Your name: " + value;
}
// ERROR IS FLAGGED ON LINE 30 BELOW
public static DialogResult InputBox(string title, string promptText, ref string value)
{
Form form = new Form();
Label label = new Label();
TextBox textBox = new TextBox();
Button buttonOk = new Button();
Button buttonCancel = new Button();
form.Text = title;
label.Text = promptText;
buttonOk.Text = "OK";
buttonCancel.Text = "Cancel";
buttonOk.DialogResult = DialogResult.OK;
buttonCancel.DialogResult = DialogResult.Cancel;
label.SetBounds(36, 36, 372, 13);
textBox.SetBounds(36, 86, 700, 20);
buttonOk.SetBounds(228, 160, 160, 60);
buttonCancel.SetBounds(400, 160, 160, 60);
label.AutoSize = true;
form.ClientSize = new Size(796, 307);
form.FormBorderStyle = FormBorderStyle.FixedDialog;
form.StartPosition = FormStartPosition.CenterScreen;
form.MinimizeBox = false;
form.MaximizeBox = false;
form.Controls.AddRange(new Control[] { label, textBox, buttonOk, buttonCancel });
form.AcceptButton = buttonOk;
form.CancelButton = buttonCancel;
DialogResult dialogResult = form.ShowDialog();
value = textBox.Text;
return dialogResult;
}
}
}
}