Finally and c# reference types -


i not able figure how work:

public class1 function1() {    datatable dt;    try    {      dt = new datatable();      //.. work      return new class2(byref dt);    }       {       dt.dispose();    } }   public class2(byref datatable dtable) {     this.datatable = dtable; } 

so, if class1 obj1 = function1(); obj1.datatable disposed? or have proper data?

yes assuming obj1.datatable refers same object created inside function1, have been disposed. finally blocks executed, regardless of whether exception thrown or not.

here's more information on try-finally blocks.


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

qt - Errors in generated MOC files for QT5 from cmake -