c# - Generate and Dispose before using? -


today intstructor, i'm intern, said should use

    himage hi = null;      hoperatorset.genemptyobject(out hi);     hi.dispose();      hi = f.grabimageasync(-1.0); 

instead of

    himage hi = null;      hi = f.grabimageasync(-1.0); 

prototypes of used functions follows

    void hoperatorset.genemptyobj(out hobject emptyobject);     himage hframegrabber.grabimageasync(double maxdelay); 

i respect instructor ,but don't see meaningful explanation @ creating , disposing object before calling hi = f.grabimageasync(-1.0); functions returns instance of object , therefore no need generating , disposing object first, @ least in opinion.

so can clarify if needed or not. thank in advance.

i agree you. there no use in creating , disposing variable.

as far can see code, hoperatorset.genemptyobject doesn't interact f variable, there no meaning in calling method.

also, there no point in setting himage hi null, since default , set using out parameter.

so bet on:

himage hi = f.grabimageasync(-1.0); 

Comments