Hello i am trying to solve the second part of this question
i am getting these errors
Error 2 Only assignment, call, increment, decrement, and new object expressions can be used as a statement
Error 1 Use of unassigned local variable 'i'
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace EmployeeExceptionDemo2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
Employee[] emp = new Employee[5];
private void button1_Click(object sender, EventArgs e)
{
int id;
double wage;
for (int i; i < 5; i++)
{
label3.Text = " Employee " + (i + 1) + " ID # ";
id = Convert.ToInt32(textBox1.Text);
label3.Text += "Hourly Wage ";
wage = Convert.ToDouble(textBox2.Text);
emp[i] = new Employee(id, wage);
}
label3.Text = " Display Employee details\n ID Number\t\tHourlyWage";
}
public class Employee
{
int IDNum;
double hourlyWage;
public Employee() { }
public Employee(int id, double hw)
{
try
{
IDNum = id;
if (hw < 6 || hw > 50)
throw new ArgumentException("Invalid Value", "houlyWage");
else
{
// label3.Text = "Employee Object Created Successfully";
hourlyWage = hw;
}
}
catch (ArgumentException ae)
{
IDNum = 999;
hourlyWage = 6.0;
(ae.Message);
}
}
}
}
}