G
Guest
When I try to compile the code below I receive a first chance exception. I've
noticed from searching on the web that some people choose to ignore first
chance exceptions. Is this common practice? Do you guys see anything wrong
with my code or should I ignore the exception it generates?
<Using directives here>
namespace Settings
{
enum DisplacementUnits { Feet, Kilofeet, Meters, Kilometers, NauticalMiles };
abstract class Variable
{
public abstract int Unit
{
get;
set;
}
public double Value //Using another name doesn't help
{
get
{
return Value;
}
set
{
Value = value; //Generates a A first chance exception of type
'System.StackOverflowException'
}
}
}
class DisplacementVariable : Variable
{
public override int Unit
{
get
{
return Unit;
}
set
{
Console.WriteLine("set");
}
}
public DisplacementVariable()
{
Unit = (int)DisplacementUnits.Feet;
Value = 0;
}
public DisplacementVariable(double value, int unit)
{
Unit = unit;
Value = value;
}
}
class Settings
{
double someVar1;
string someVar2;
static void Main(string[] args)
{
DisplacementVariable x = new DisplacementVariable(0,0);
Console.WriteLine("in main..");
Console.ReadLine();
}
}
}
I'm using VS2005 beta1.
noticed from searching on the web that some people choose to ignore first
chance exceptions. Is this common practice? Do you guys see anything wrong
with my code or should I ignore the exception it generates?
<Using directives here>
namespace Settings
{
enum DisplacementUnits { Feet, Kilofeet, Meters, Kilometers, NauticalMiles };
abstract class Variable
{
public abstract int Unit
{
get;
set;
}
public double Value //Using another name doesn't help
{
get
{
return Value;
}
set
{
Value = value; //Generates a A first chance exception of type
'System.StackOverflowException'
}
}
}
class DisplacementVariable : Variable
{
public override int Unit
{
get
{
return Unit;
}
set
{
Console.WriteLine("set");
}
}
public DisplacementVariable()
{
Unit = (int)DisplacementUnits.Feet;
Value = 0;
}
public DisplacementVariable(double value, int unit)
{
Unit = unit;
Value = value;
}
}
class Settings
{
double someVar1;
string someVar2;
static void Main(string[] args)
{
DisplacementVariable x = new DisplacementVariable(0,0);
Console.WriteLine("in main..");
Console.ReadLine();
}
}
}
I'm using VS2005 beta1.