N
nicol
Hi
I have a problem at this program a bout the usage of this()
Error 1 The name 'first' does not exist in the current context
Error 2 The name 'lname' does not exist in the current context
using System;
class Program
{
static void Main(string[] args)
{
employee first = new employee ( "peter", "young" );
employee id = new employee();
id.Id=int.Parse(Console.ReadLine());
employee salary = new employee();
salary.Salary = int.Parse(Console.ReadLine());
}
}
class employee
{
#region private fields
private decimal salary;
private int id;
#endregion
public decimal Salary
{
set
{
if (value > 0)
salary = value;
else
{
Exception ex = new Exception(" invalid id");
throw ex;
}
}
}
public int Id
{
set
{
if (value > 0)
id = value;
else
{
Exception e = new Exception("invalid number !");
throw e;
}
}
}
#region public fields
public string first_name;
public string last_name;
#endregion;
// constructurs
public employee(string fname, string lname):this()
{
first_name = fname;
last_name = lname;
}
public employee():this( first, lname) // error*******
{
}
}
I have a problem at this program a bout the usage of this()
Error 1 The name 'first' does not exist in the current context
Error 2 The name 'lname' does not exist in the current context
using System;
class Program
{
static void Main(string[] args)
{
employee first = new employee ( "peter", "young" );
employee id = new employee();
id.Id=int.Parse(Console.ReadLine());
employee salary = new employee();
salary.Salary = int.Parse(Console.ReadLine());
}
}
class employee
{
#region private fields
private decimal salary;
private int id;
#endregion
public decimal Salary
{
set
{
if (value > 0)
salary = value;
else
{
Exception ex = new Exception(" invalid id");
throw ex;
}
}
}
public int Id
{
set
{
if (value > 0)
id = value;
else
{
Exception e = new Exception("invalid number !");
throw e;
}
}
}
#region public fields
public string first_name;
public string last_name;
#endregion;
// constructurs
public employee(string fname, string lname):this()
{
first_name = fname;
last_name = lname;
}
public employee():this( first, lname) // error*******
{
}
}