This is a code automatically converted from VB 6.0 to C#.net
What is a safe and correct way to get rid of that GOTO
statement?
public bool IsDirty(bool checkChildrenInd)
{
bool result = false;
//Determine if this object is 'dirty', or has been updated since it was created.
if (Parent.NewInd)
{
return true;
}
if (backup == null)
{
goto CheckChildren; //Check any child lists
}
if (!String.Equals(MissingDataValue, backup.MissingDataValue))
{
return true;
}
if (!String.Equals(PreviewDataValue, backup.PreviewDataValue))
{
return true;
}
if (FieldOption != backup.FieldOption)
{
return true;
}
CheckChildren:
if (!checkChildrenInd)
{
return result;
}
return result;
}
public bool IsDirty(bool checkChildrenInd){ return Parent.NewId || backup != null)
\$\endgroup\$// do something
in the places where your code might (or not) do something. (Just make sure that the "do something" has no side-effects to the existing instructions... otherwise it's required, for the refactor.) \$\endgroup\$