samedi 12 décembre 2015

how to implement an early return (or override return) with void Method rather bool()

i was trying to do something like the code below to avoid using a Boolean return type method, and i couldn't find any way to implement it correctly:

public void myMethod(int someInitializingParameter)
{
                                              //return (kinda override operator)
     if(TargetObjToinitItsProperties == null) MsgDbgWinShow("Error: Line#637-xxx.CS", "Property was accessed prior to parent object init");
     TargetObjToInitItsProperties.IntProp1 = someInitializingParameter;
}

static void MsgDbgWinShow(string Wtitle, string Wmsg)
{
   create a window (windowsTitle=Wtitle .. size width ...create TextBlock.Content= Wmsg...etc')

   CreatedWindow.Show();
//here is self exit and return ...from self but will not act as return operator...
}

is there any approach to use void as return type rather using a Type?

Aucun commentaire:

Enregistrer un commentaire