L
Leif Eirik Olsen
Hi,
I have a class Test with a property Active. Setter and getter is
implemented.
Setter ~
set
{
try
{
if (SomeValue) throw new Exception("Error");
else FActive = value
}
catch (System.Exception ex)
{ MessageBox.Show(ex.Message)}
}
In my main application that uses this Test class I code something like this:
Test aTest = new Test;
aTest.Active = true;
Do other stuff1
Do other stuff2
....
My problem: How do I break execution on the line "aTest.Active = true;" if
the setting of the Active property raised an exception ?
In other words: I do not want to execute "do other stuff1 & 2" if an
exception was raised on the previous line.
I know I can solve this by doing this:
Test aTest = new Test;
aTest.Active = true;
if (aTest.Active)
{
Do other stuff1
Do other stuff2
...
}
, but this does not feel right
any hints or help greatly appriciated.
regards,
Leo
I have a class Test with a property Active. Setter and getter is
implemented.
Setter ~
set
{
try
{
if (SomeValue) throw new Exception("Error");
else FActive = value
}
catch (System.Exception ex)
{ MessageBox.Show(ex.Message)}
}
In my main application that uses this Test class I code something like this:
Test aTest = new Test;
aTest.Active = true;
Do other stuff1
Do other stuff2
....
My problem: How do I break execution on the line "aTest.Active = true;" if
the setting of the Active property raised an exception ?
In other words: I do not want to execute "do other stuff1 & 2" if an
exception was raised on the previous line.
I know I can solve this by doing this:
Test aTest = new Test;
aTest.Active = true;
if (aTest.Active)
{
Do other stuff1
Do other stuff2
...
}
, but this does not feel right

any hints or help greatly appriciated.
regards,
Leo