As
Suvendu Shekhar Giri already pointed out, your
PetType
instance, namely
pet
is bad scoped: it is accessible just inside the try block.
You have to declare it before the try block and the instantiate it inside the try block itself.
PetType pet;
try
{
pet = ...
Please see:
Variable and Method Scope in Microsoft .NET[
^].
[update]
Fixed, thanks to
Richard.
[/update]