Question: So I get back errors using this code: using System; using System.Windows.Forms; namespace RaisingSalaryGUI { public partial class Form 1 : Form { public Form

So I get back errors using this code:
using System;
using System.Windows.Forms;
namespace RaisingSalaryGUI
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private partial void Button1_click(object sender, EventArgs e);
}
namespace ProjectedRaisesGUI
{
public class Form1 : Form
{
private readonly Label lblCurrentSalary;
private readonly TextBox txtCurrentSalary;
private readonly Button btnCalculate;
private Label lblResult;
public Form1()
{
lblCurrentSalary = new Label();
txtCurrentSalary = new TextBox();
btnCalculate = new Button();
lblResult = new Label();
lblCurrentSalary.Text = "Current Salary";
lblCurrentSalary.Location = new System.Drawing.Point(10,20);
lblCurrentSalary.AutoSize = true;
txtCurrentSalary.Location = new System.Drawing.Point(150,20);
txtCurrentSalary.Width =100;
btnCalculate.Text = "Calculate";
btnCalculate.Location = new System.Drawing.Point(10,60);
btnCalculate.Click += new System.EventHandler(BtnCalculate_Click);
lblResult.Location = new System.Drawing.Point(10,100);
lblResult.AutoSize = true;
this.Controls.Add(lblCurrentSalary);
this.Controls.Add(txtCurrentSalary);
this.Controls.Add(btnCalculate);
this.Controls.Add(lblResult);
this.Text = "Projected Salary Calculator";
this.StartPosition = FormStartPosition.CenterScreen;
this.Size = new System.Drawing.Size(300,200);
}
private void BtnCalculate_Click(object sender, System.EventArgs e)
{
try
{
double currentSalary = System.Convert.ToDouble(txtCurrentSalary.Text);
double increaseRate =0.04;
double projectedSalary = currentSalary *(1+ increaseRate);
lblResult.Text = $"New Salary ${projectedSalary:F2}";
}
catch (System.FormatException)
{
MessageBox.Show("Please enter a valid number for the salary.", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
[System.STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
}
}
}
and these are the errors:
Severity Code Description Project File Line Suppression State
Error (active) CS0017 Program has more than one entry point defined. Compile with /main to specify the type that contains the entry point.
Severity Code Description Project File Line Suppression State
Error (active) CS8795 Partial method 'Form1.Button1_click(object, EventArgs)' must have an implementation part because it has accessibility modifiers.
Severity Code Description Project File Line Suppression State
Error (active) CS8370 Feature 'extended partial methods' is not available in C# 7.3. Please use language version 9.0 or greater.
Severity Code Description Project File Line Suppression State
Error (active) CS0762 Cannot create delegate from method 'Form1.Button1_click(object, EventArgs)' because it is a partial method without an implementing declaration
It has to be in C#.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!