{"id":63,"date":"2014-05-23T05:43:00","date_gmt":"2014-05-23T04:43:00","guid":{"rendered":"https:\/\/debuggersspace.com\/index.php\/2014\/05\/23\/what-is-the-use-significance-of-dispose-and-finalize-method\/"},"modified":"2014-05-23T05:43:00","modified_gmt":"2014-05-23T04:43:00","slug":"what-is-the-use-significance-of-dispose-and-finalize-method","status":"publish","type":"post","link":"https:\/\/debuggersspace.com\/index.php\/2014\/05\/23\/what-is-the-use-significance-of-dispose-and-finalize-method\/","title":{"rendered":"What is the use\/significance of Dispose and Finalize method?"},"content":{"rendered":"<div class='booster-block booster-read-block'>\n                <div class=\"twp-read-time\">\n                \t<i class=\"booster-icon twp-clock\"><\/i> <span>Read Time:<\/span>4 Minute, 55 Second                <\/div>\n\n            <\/div><div dir=\"ltr\" style=\"text-align: left;\">\n<div style=\"background: white; line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;\">\n<span style=\"color: black; font-family: &quot;verdana&quot; , &quot;sans-serif&quot;; font-size: 10.0pt;\">.NET Framework provides two methods Finalize and Dispose for<br \/>\nreleasing unmanaged resources like:&nbsp;<\/span><span style=\"color: #111111; font-family: &quot;verdana&quot; , &quot;sans-serif&quot;; font-size: 10.0pt;\">Windows API created objects, File,<br \/>\nDatabase connection objects, COM objects<\/span><span style=\"color: black; font-family: &quot;verdana&quot; , &quot;sans-serif&quot;; font-size: 10.0pt;\">.<\/span><span style=\"color: black; font-family: &quot;verdana&quot; , &quot;sans-serif&quot;; font-size: 10.0pt;\"><o:p><\/o:p><\/span><\/div>\n<div style=\"background: white; line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;\">\n<span style=\"color: black; font-family: &quot;verdana&quot; , &quot;sans-serif&quot;; font-size: 10.0pt;\">It is always recommended to use Dispose method to clean<br \/>\nunmanaged resources. Do not implement the Finalize method until it is extremely<br \/>\nnecessary<\/span><span style=\"color: black; font-family: &quot;verdana&quot; , &quot;sans-serif&quot;; font-size: 10.0pt;\"><o:p><\/o:p><\/span><\/div>\n<div style=\"background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;\">\n<u><span style=\"color: #111111; font-family: &quot;verdana&quot; , &quot;sans-serif&quot;; font-size: 10.0pt;\">Dispose:<\/span><\/u><span style=\"color: #111111; font-family: &quot;verdana&quot; , &quot;sans-serif&quot;; font-size: 10.0pt;\"><o:p><\/o:p><\/span><\/div>\n<div style=\"background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;\">\n<\/div>\n<div style=\"background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;\">\n<span style=\"color: #990000; font-family: &quot;verdana&quot; , &quot;sans-serif&quot;; font-size: 10.0pt;\">Dispose&nbsp;<\/span><span style=\"color: #111111; font-family: &quot;verdana&quot; , &quot;sans-serif&quot;; font-size: 10.0pt;\">method belongs to \u2018<\/span><span style=\"color: #990000; font-family: &quot;verdana&quot; , &quot;sans-serif&quot;; font-size: 10.0pt;\">IDisposable<\/span><span style=\"color: #111111; font-family: &quot;verdana&quot; , &quot;sans-serif&quot;; font-size: 10.0pt;\">\u2019 interface. If any<br \/>\nobject wants to release its unmanaged code, the best is to implement&nbsp;<\/span><span style=\"color: #990000; font-family: &quot;verdana&quot; , &quot;sans-serif&quot;; font-size: 10.0pt;\">IDisposable&nbsp;<\/span><span style=\"color: #111111; font-family: &quot;verdana&quot; , &quot;sans-serif&quot;; font-size: 10.0pt;\">and override<br \/>\nthe&nbsp;<\/span><span style=\"color: #990000; font-family: &quot;verdana&quot; , &quot;sans-serif&quot;; font-size: 10.0pt;\">Dispose&nbsp;<\/span><span style=\"color: #111111; font-family: &quot;verdana&quot; , &quot;sans-serif&quot;; font-size: 10.0pt;\">method&nbsp; of&nbsp;<\/span><span style=\"color: #990000; font-family: &quot;verdana&quot; , &quot;sans-serif&quot;; font-size: 10.0pt;\">IDisposable&nbsp;<\/span><span style=\"color: #111111; font-family: &quot;verdana&quot; , &quot;sans-serif&quot;; font-size: 10.0pt;\">interface. Now once<br \/>\nyour class has exposed the&nbsp;<\/span><span style=\"color: #990000; font-family: &quot;verdana&quot; , &quot;sans-serif&quot;; font-size: 10.0pt;\">Dispose<\/span><span style=\"color: #111111; font-family: &quot;verdana&quot; , &quot;sans-serif&quot;; font-size: 10.0pt;\">&nbsp;method, it is<br \/>\nthe responsibility of the client to call the&nbsp;<\/span><span style=\"color: #990000; font-family: &quot;verdana&quot; , &quot;sans-serif&quot;; font-size: 10.0pt;\">Dispose&nbsp;<\/span><span style=\"color: #111111; font-family: &quot;verdana&quot; , &quot;sans-serif&quot;; font-size: 10.0pt;\">method to do the<br \/>\ncleanup.&nbsp;<\/span><br \/>\n<span style=\"color: #111111; font-family: &quot;verdana&quot; , &quot;sans-serif&quot;; font-size: 10.0pt;\"><br \/><\/span><\/div>\n<div style=\"background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;\">\n<span style=\"color: #111111; font-family: &quot;verdana&quot; , &quot;sans-serif&quot;; font-size: 10.0pt;\"><br \/>\n<!--[if !supportLineBreakNewLine]--><br style=\"mso-special-character: line-break;\" \/><br \/>\n<!--[endif]--><\/span><span style=\"color: #111111; font-family: &quot;verdana&quot; , &quot;sans-serif&quot;; font-size: 10.0pt;\"><o:p><\/o:p><\/span><\/div>\n<div style=\"background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;\">\n<b><span style=\"color: #111111; font-family: &quot;verdana&quot; , &quot;sans-serif&quot;; font-size: 10.0pt;\">How do I force the&nbsp;<\/span><\/b><b><span style=\"color: black; font-family: &quot;verdana&quot; , &quot;sans-serif&quot;; font-size: 10.0pt;\">Dispose&nbsp;<\/span><\/b><b><span style=\"color: #111111; font-family: &quot;verdana&quot; , &quot;sans-serif&quot;; font-size: 10.0pt;\">method to be called<br \/>\nautomatically, as clients can forget to call&nbsp;<\/span><\/b><b><span style=\"color: black; font-family: &quot;verdana&quot; , &quot;sans-serif&quot;; font-size: 10.0pt;\">Dispose&nbsp;<\/span><\/b><b><span style=\"color: #111111; font-family: &quot;verdana&quot; , &quot;sans-serif&quot;; font-size: 10.0pt;\">method?<\/span><\/b><span style=\"color: #111111; font-family: &quot;verdana&quot; , &quot;sans-serif&quot;; font-size: 10.0pt;\"><o:p><\/o:p><\/span><\/div>\n<div style=\"background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;\">\n<\/div>\n<div style=\"background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;\">\n<span style=\"color: #111111; font-family: &quot;verdana&quot; , &quot;sans-serif&quot;; font-size: 10.0pt;\">Call the&nbsp;<\/span><span style=\"color: #990000; font-family: &quot;verdana&quot; , &quot;sans-serif&quot;; font-size: 10.0pt;\">Dispose&nbsp;<\/span><span style=\"color: #111111; font-family: &quot;verdana&quot; , &quot;sans-serif&quot;; font-size: 10.0pt;\">method in&nbsp;<\/span><span style=\"color: #990000; font-family: &quot;verdana&quot; , &quot;sans-serif&quot;; font-size: 10.0pt;\">Finalize&nbsp;<\/span><span style=\"color: #111111; font-family: &quot;verdana&quot; , &quot;sans-serif&quot;; font-size: 10.0pt;\">method and in&nbsp;<\/span><span style=\"color: #990000; font-family: &quot;verdana&quot; , &quot;sans-serif&quot;; font-size: 10.0pt;\">Dispose&nbsp;<\/span><span style=\"color: #111111; font-family: &quot;verdana&quot; , &quot;sans-serif&quot;; font-size: 10.0pt;\">method, suppress<br \/>\nthe&nbsp;<\/span><span style=\"color: #990000; font-family: &quot;verdana&quot; , &quot;sans-serif&quot;; font-size: 10.0pt;\">finalize&nbsp;<\/span><span style=\"color: #111111; font-family: &quot;verdana&quot; , &quot;sans-serif&quot;; font-size: 10.0pt;\">method using&nbsp;<\/span><span style=\"color: #990000; font-family: &quot;verdana&quot; , &quot;sans-serif&quot;; font-size: 10.0pt;\">GC.SuppressFinalize<\/span><span style=\"color: #111111; font-family: &quot;verdana&quot; , &quot;sans-serif&quot;; font-size: 10.0pt;\">. <o:p><\/o:p><\/span><\/div>\n<div style=\"background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;\">\n<\/div>\n<div style=\"background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;\">\n<span style=\"color: #111111; font-family: &quot;verdana&quot; , &quot;sans-serif&quot;; font-size: 10.0pt;\">Below is the sample code of the pattern. This is the best way we<br \/>\ndo clean our unallocated resources and yes not to forget we do not get the hit<br \/>\nof running the Garbage collector twice.<br style=\"mso-special-character: line-break;\" \/><br \/>\n<!--[if !supportLineBreakNewLine]--><br style=\"mso-special-character: line-break;\" \/><br \/>\n<!--[endif]--><\/span><span style=\"color: #111111; font-family: &quot;verdana&quot; , &quot;sans-serif&quot;; font-size: 10.0pt;\"><o:p><\/o:p><\/span><\/div>\n<div style=\"background: #FBEDBB; border: solid #FBEDBB 1.0pt; mso-border-alt: solid #FBEDBB .5pt; mso-element: para-border-div; padding: 3.0pt 3.0pt 3.0pt 3.0pt;\">\n<div style=\"background: #FBEDBB; border: none; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-border-alt: solid #FBEDBB .5pt; mso-padding-alt: 3.0pt 3.0pt 3.0pt 3.0pt; padding: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;\">\n<span style=\"color: black; font-family: &quot;verdana&quot; , &quot;sans-serif&quot;; font-size: 10.0pt;\"><span style=\"mso-spacerun: yes;\">&nbsp;<\/span><\/span><span lang=\"CS\" style=\"border: none 1.0pt; color: blue; font-family: &quot;verdana&quot; , &quot;sans-serif&quot;; font-size: 10.0pt; padding: 0in;\">public<\/span><span lang=\"CS\" style=\"color: black; font-family: &quot;verdana&quot; , &quot;sans-serif&quot;; font-size: 10.0pt;\"> <\/span><span lang=\"CS\" style=\"border: none 1.0pt; color: blue; font-family: &quot;verdana&quot; , &quot;sans-serif&quot;; font-size: 10.0pt; padding: 0in;\">class<\/span><span lang=\"CS\" style=\"color: black; font-family: &quot;verdana&quot; , &quot;sans-serif&quot;; font-size: 10.0pt;\"> CleanClass :<br \/>\nIDisposable<o:p><\/o:p><\/span><\/div>\n<div style=\"background: #FBEDBB; border: none; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-border-alt: solid #FBEDBB .5pt; mso-padding-alt: 3.0pt 3.0pt 3.0pt 3.0pt; padding: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;\">\n<span lang=\"CS\" style=\"color: black; font-family: &quot;verdana&quot; , &quot;sans-serif&quot;; font-size: 10.0pt;\"><span style=\"mso-spacerun: yes;\">&nbsp;&nbsp;&nbsp; <\/span>{<o:p><\/o:p><\/span><\/div>\n<div style=\"background: #FBEDBB; border: none; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-border-alt: solid #FBEDBB .5pt; mso-padding-alt: 3.0pt 3.0pt 3.0pt 3.0pt; padding: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;\">\n<span lang=\"CS\" style=\"color: black; font-family: &quot;verdana&quot; , &quot;sans-serif&quot;; font-size: 10.0pt;\"><span style=\"mso-spacerun: yes;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><\/span><span lang=\"CS\" style=\"border: none 1.0pt; color: blue; font-family: &quot;verdana&quot; , &quot;sans-serif&quot;; font-size: 10.0pt; padding: 0in;\">public<\/span><span lang=\"CS\" style=\"color: black; font-family: &quot;verdana&quot; , &quot;sans-serif&quot;; font-size: 10.0pt;\"> <\/span><span lang=\"CS\" style=\"border: none 1.0pt; color: blue; font-family: &quot;verdana&quot; , &quot;sans-serif&quot;; font-size: 10.0pt; padding: 0in;\">void<\/span><span lang=\"CS\" style=\"color: black; font-family: &quot;verdana&quot; , &quot;sans-serif&quot;; font-size: 10.0pt;\"> Dispose()<o:p><\/o:p><\/span><\/div>\n<div style=\"background: #FBEDBB; border: none; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-border-alt: solid #FBEDBB .5pt; mso-padding-alt: 3.0pt 3.0pt 3.0pt 3.0pt; padding: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;\">\n<span lang=\"CS\" style=\"color: black; font-family: &quot;verdana&quot; , &quot;sans-serif&quot;; font-size: 10.0pt;\"><span style=\"mso-spacerun: yes;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>{<o:p><\/o:p><\/span><\/div>\n<div style=\"background: #FBEDBB; border: none; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-border-alt: solid #FBEDBB .5pt; mso-padding-alt: 3.0pt 3.0pt 3.0pt 3.0pt; padding: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;\">\n<span lang=\"CS\" style=\"color: black; font-family: &quot;verdana&quot; , &quot;sans-serif&quot;; font-size: 10.0pt;\"><span style=\"mso-spacerun: yes;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>GC.SuppressFinalize(<\/span><span lang=\"CS\" style=\"border: none 1.0pt; color: blue; font-family: &quot;verdana&quot; , &quot;sans-serif&quot;; font-size: 10.0pt; padding: 0in;\">this<\/span><span lang=\"CS\" style=\"color: black; font-family: &quot;verdana&quot; , &quot;sans-serif&quot;; font-size: 10.0pt;\">);<o:p><\/o:p><\/span><\/div>\n<div style=\"background: #FBEDBB; border: none; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-border-alt: solid #FBEDBB .5pt; mso-padding-alt: 3.0pt 3.0pt 3.0pt 3.0pt; padding: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;\">\n<span lang=\"CS\" style=\"color: black; font-family: &quot;verdana&quot; , &quot;sans-serif&quot;; font-size: 10.0pt;\"><span style=\"mso-spacerun: yes;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>}<o:p><\/o:p><\/span><\/div>\n<div style=\"background: #FBEDBB; border: none; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-border-alt: solid #FBEDBB .5pt; mso-padding-alt: 3.0pt 3.0pt 3.0pt 3.0pt; padding: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;\">\n<span lang=\"CS\" style=\"color: black; font-family: &quot;verdana&quot; , &quot;sans-serif&quot;; font-size: 10.0pt;\"><span style=\"mso-spacerun: yes;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><o:p><\/o:p><\/span><\/div>\n<div style=\"background: #FBEDBB; border: none; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-border-alt: solid #FBEDBB .5pt; mso-padding-alt: 3.0pt 3.0pt 3.0pt 3.0pt; padding: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;\">\n<span lang=\"CS\" style=\"color: black; font-family: &quot;verdana&quot; , &quot;sans-serif&quot;; font-size: 10.0pt;\"><span style=\"mso-spacerun: yes;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>~CleanClass()<o:p><\/o:p><\/span><\/div>\n<div style=\"background: #FBEDBB; border: none; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-border-alt: solid #FBEDBB .5pt; mso-padding-alt: 3.0pt 3.0pt 3.0pt 3.0pt; padding: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;\">\n<span lang=\"CS\" style=\"color: black; font-family: &quot;verdana&quot; , &quot;sans-serif&quot;; font-size: 10.0pt;\"><span style=\"mso-spacerun: yes;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>{<o:p><\/o:p><\/span><\/div>\n<div style=\"background: #FBEDBB; border: none; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-border-alt: solid #FBEDBB .5pt; mso-padding-alt: 3.0pt 3.0pt 3.0pt 3.0pt; padding: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;\">\n<span lang=\"CS\" style=\"color: black; font-family: &quot;verdana&quot; , &quot;sans-serif&quot;; font-size: 10.0pt;\"><span style=\"mso-spacerun: yes;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>Dispose();<o:p><\/o:p><\/span><\/div>\n<div style=\"background: #FBEDBB; border: none; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-border-alt: solid #FBEDBB .5pt; mso-padding-alt: 3.0pt 3.0pt 3.0pt 3.0pt; padding: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;\">\n<span lang=\"CS\" style=\"color: black; font-family: &quot;verdana&quot; , &quot;sans-serif&quot;; font-size: 10.0pt;\"><span style=\"mso-spacerun: yes;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>}<o:p><\/o:p><\/span><\/div>\n<div style=\"background: #FBEDBB; border: none; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-border-alt: solid #FBEDBB .5pt; mso-padding-alt: 3.0pt 3.0pt 3.0pt 3.0pt; padding: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;\">\n<span lang=\"CS\" style=\"color: black; font-family: &quot;verdana&quot; , &quot;sans-serif&quot;; font-size: 10.0pt;\"><span style=\"mso-spacerun: yes;\">&nbsp;&nbsp;&nbsp; <\/span>} <\/span><span lang=\"CS\" style=\"color: black; font-family: &quot;verdana&quot; , &quot;sans-serif&quot;; font-size: 10.0pt;\"><o:p><\/o:p><\/span><\/div>\n<\/div>\n<div style=\"background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;\">\n<span style=\"color: #111111; font-family: &quot;verdana&quot; , &quot;sans-serif&quot;; font-size: 10.0pt;\"><br \/>\n<\/span><u><span style=\"color: black; font-family: &quot;verdana&quot; , &quot;sans-serif&quot;; font-size: 10.0pt;\">Finalize:<\/span><\/u><span style=\"color: #111111; font-family: &quot;verdana&quot; , &quot;sans-serif&quot;; font-size: 10.0pt;\"><o:p><\/o:p><\/span><\/div>\n<div style=\"background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;\">\n<span style=\"color: #111111; font-family: &quot;verdana&quot; , &quot;sans-serif&quot;; font-size: 10.0pt;\"><br \/>\n.NET Garbage collector does almost all clean up activity for your objects. But<br \/>\nunmanaged resources (example: Windows API created objects, File, Database<br \/>\nconnection objects, COM objects, etc.) are outside the scope of .NET Framework.<br \/>\nWe have to explicitly clean our resources. For these types of objects, .NET<br \/>\nFramework provides<\/span><span style=\"color: #990000; font-family: &quot;verdana&quot; , &quot;sans-serif&quot;; font-size: 10.0pt;\">Object.Finalize&nbsp;<\/span><span style=\"color: #111111; font-family: &quot;verdana&quot; , &quot;sans-serif&quot;; font-size: 10.0pt;\">method.<\/span><span style=\"color: #111111; font-family: &quot;verdana&quot; , &quot;sans-serif&quot;; font-size: 10.0pt;\"><o:p><\/o:p><\/span><\/div>\n<div style=\"background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;\">\n<\/div>\n<div style=\"background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;\">\n<span style=\"color: black; font-family: &quot;verdana&quot; , &quot;sans-serif&quot;; font-size: 10.0pt;\"><br \/>\n<b>What is the difference between Finalize() and Dispose() methods?<\/b><\/span><span style=\"color: black; font-family: &quot;verdana&quot; , &quot;sans-serif&quot;; font-size: 10.0pt;\"><o:p><\/o:p><\/span><\/div>\n<div style=\"background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;\">\n<\/div>\n<div style=\"background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;\">\n<u><span style=\"color: #111111; font-family: &quot;verdana&quot; , &quot;sans-serif&quot;; font-size: 10.0pt;\">Dispose:<\/span><\/u><span style=\"color: #111111; font-family: &quot;verdana&quot; , &quot;sans-serif&quot;; font-size: 10.0pt;\"><o:p><\/o:p><\/span><\/div>\n<ol start=\"1\" type=\"1\">\n<li style=\"background: white; color: black; line-height: normal; mso-list: l1 level1 lfo1; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list .5in;\"><span style=\"font-family: &quot;verdana&quot; , &quot;sans-serif&quot;; font-size: 10.0pt;\">Dispose<br \/>\n     It belongs to IDisposable interface. and internal called by user code.<\/span><span style=\"font-family: &quot;verdana&quot; , &quot;sans-serif&quot;; font-size: 10.0pt;\"><o:p><\/o:p><\/span><\/li>\n<li style=\"background: white; color: black; line-height: normal; mso-list: l1 level1 lfo1; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list .5in;\"><span style=\"font-family: &quot;verdana&quot; , &quot;sans-serif&quot;; font-size: 10.0pt;\">Dispose<br \/>\n     () of IDisposable interface is called by the programmer to explicitly<br \/>\n     release resources when they are no longer being used. Dispose () can be<br \/>\n     called even if other references to the object are alive.<\/span><span style=\"font-family: &quot;verdana&quot; , &quot;sans-serif&quot;; font-size: 10.0pt;\"><o:p><\/o:p><\/span><\/li>\n<li style=\"background: white; color: black; line-height: normal; mso-list: l1 level1 lfo1; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list .5in;\"><span style=\"font-family: &quot;verdana&quot; , &quot;sans-serif&quot;; font-size: 10.0pt;\">It<br \/>\n     is called by user code and the class implementing dispose method must<br \/>\n     implement IDisposable interface.It belongs to IDisposable<br \/>\n     interface.Implement this when you are writing a custom class that will be<br \/>\n     used by other users.There is no performance costs associated with Dispose<br \/>\n     method<\/span><span style=\"font-family: &quot;verdana&quot; , &quot;sans-serif&quot;; font-size: 10.0pt;\"><o:p><\/o:p><\/span><\/li>\n<\/ol>\n<div style=\"background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;\">\n<u><span style=\"color: black; font-family: &quot;verdana&quot; , &quot;sans-serif&quot;; font-size: 10.0pt;\">Finalize:<\/span><\/u><span style=\"color: black; font-family: &quot;verdana&quot; , &quot;sans-serif&quot;; font-size: 10.0pt;\"><o:p><\/o:p><\/span><\/div>\n<ol start=\"1\" type=\"1\">\n<li style=\"background: white; color: black; line-height: normal; mso-list: l0 level1 lfo2; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list .5in;\"><span style=\"font-family: &quot;verdana&quot; , &quot;sans-serif&quot;; font-size: 10.0pt;\">Finalize<br \/>\n     It belongs to Object class. and It&#8217;s implemented with the help of<br \/>\n     destructor in C#.<\/span><span style=\"font-family: &quot;verdana&quot; , &quot;sans-serif&quot;; font-size: 10.0pt;\"><o:p><\/o:p><\/span><\/li>\n<li style=\"background: white; color: black; line-height: normal; mso-list: l0 level1 lfo2; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list .5in;\"><span style=\"font-family: &quot;verdana&quot; , &quot;sans-serif&quot;; font-size: 10.0pt;\">Used<br \/>\n     to free unmanaged resources like files, database connections, COM etc.<br \/>\n     held by an object before that object is destroyed.Internally, it is called<br \/>\n     by Garbage Collector and cannot be called by user code.<\/span><span style=\"font-family: &quot;verdana&quot; , &quot;sans-serif&quot;; font-size: 10.0pt;\"><o:p><\/o:p><\/span><\/li>\n<li style=\"background: white; color: black; line-height: normal; mso-list: l0 level1 lfo2; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list .5in;\"><span style=\"font-family: &quot;verdana&quot; , &quot;sans-serif&quot;; font-size: 10.0pt;\">The<br \/>\n     finalizer method is called when your object is garbage collected and you<br \/>\n     have no guarantee when this will happen (you can force it, but it will<br \/>\n     hurt performance).<\/span><span style=\"font-family: &quot;verdana&quot; , &quot;sans-serif&quot;; font-size: 10.0pt;\"><o:p><\/o:p><\/span><\/li>\n<\/ol>\n<div style=\"background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;\">\n<b><span style=\"color: #111111; font-family: &quot;verdana&quot; , &quot;sans-serif&quot;; font-size: 10.0pt;\"><br \/>\nWhy is it preferred to not use finalize for clean up?<\/span><\/b><span style=\"color: black; font-family: &quot;verdana&quot; , &quot;sans-serif&quot;; font-size: 10.0pt;\"><o:p><\/o:p><\/span><\/div>\n<div style=\"background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;\">\n<span style=\"color: #111111; font-family: &quot;verdana&quot; , &quot;sans-serif&quot;; font-size: 10.0pt;\"><br \/>\nThe problem with f<\/span><span style=\"color: black; font-family: &quot;verdana&quot; , &quot;sans-serif&quot;; font-size: 10.0pt;\">inalize&nbsp;<\/span><span style=\"color: #111111; font-family: &quot;verdana&quot; , &quot;sans-serif&quot;; font-size: 10.0pt;\">is that garbage collection has to make two rounds in order<br \/>\nto remove objects which have f<\/span><span style=\"color: black; font-family: &quot;verdana&quot; , &quot;sans-serif&quot;; font-size: 10.0pt;\">inalize&nbsp;<\/span><span style=\"color: #111111; font-family: &quot;verdana&quot; , &quot;sans-serif&quot;; font-size: 10.0pt;\">methods.<\/span><span style=\"color: black; font-family: &quot;verdana&quot; , &quot;sans-serif&quot;; font-size: 10.0pt;\"><o:p><\/o:p><\/span><\/div>\n<div style=\"background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;\">\n<\/div>\n<div style=\"background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;\">\n<span style=\"color: #111111; font-family: &quot;verdana&quot; , &quot;sans-serif&quot;; font-size: 10.0pt;\">Let us assume, there are three objects,&nbsp;<\/span><span style=\"color: #990000; font-family: &quot;verdana&quot; , &quot;sans-serif&quot;; font-size: 10.0pt;\">Object1<\/span><span style=\"color: #111111; font-family: &quot;verdana&quot; , &quot;sans-serif&quot;; font-size: 10.0pt;\">,&nbsp;<\/span><span style=\"color: #990000; font-family: &quot;verdana&quot; , &quot;sans-serif&quot;; font-size: 10.0pt;\">Object2<\/span><span style=\"color: #111111; font-family: &quot;verdana&quot; , &quot;sans-serif&quot;; font-size: 10.0pt;\">,&nbsp;and&nbsp;<\/span><span style=\"color: #990000; font-family: &quot;verdana&quot; , &quot;sans-serif&quot;; font-size: 10.0pt;\">Object3<\/span><span style=\"color: #111111; font-family: &quot;verdana&quot; , &quot;sans-serif&quot;; font-size: 10.0pt;\">.&nbsp;<\/span><span style=\"color: #111111; font-family: &quot;verdana&quot; , &quot;sans-serif&quot;; font-size: 10.0pt;\"><o:p><\/o:p><\/span><\/div>\n<div style=\"background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;\">\n<span style=\"color: #111111; font-family: &quot;verdana&quot; , &quot;sans-serif&quot;; font-size: 10.0pt;\"><br \/>\n<\/span><span style=\"color: #990000; font-family: &quot;verdana&quot; , &quot;sans-serif&quot;; font-size: 10.0pt;\">Object2&nbsp;<\/span><span style=\"color: #111111; font-family: &quot;verdana&quot; , &quot;sans-serif&quot;; font-size: 10.0pt;\">has the finalize method overridden and remaining objects<br \/>\ndo not have the&nbsp;<\/span><span style=\"color: #990000; font-family: &quot;verdana&quot; , &quot;sans-serif&quot;; font-size: 10.0pt;\">finalize&nbsp;<\/span><span style=\"color: #111111; font-family: &quot;verdana&quot; , &quot;sans-serif&quot;; font-size: 10.0pt;\">method overridden.<\/span><span style=\"color: #111111; font-family: &quot;verdana&quot; , &quot;sans-serif&quot;; font-size: 10.0pt;\"><o:p><\/o:p><\/span><\/div>\n<div style=\"background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;\">\n<\/div>\n<div style=\"background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;\">\n<span style=\"color: #111111; font-family: &quot;verdana&quot; , &quot;sans-serif&quot;; font-size: 10.0pt;\">Now when garbage collector runs for the first time, it searches<br \/>\nfor objects whose memory has to free. It can see three objects but only cleans<br \/>\nthe memory for&nbsp;<\/span><span style=\"color: #990000; font-family: &quot;verdana&quot; , &quot;sans-serif&quot;; font-size: 10.0pt;\">Object1&nbsp;<\/span><span style=\"color: #111111; font-family: &quot;verdana&quot; , &quot;sans-serif&quot;; font-size: 10.0pt;\">and&nbsp;<\/span><span style=\"color: #990000; font-family: &quot;verdana&quot; , &quot;sans-serif&quot;; font-size: 10.0pt;\">Object3<\/span><span style=\"color: #111111; font-family: &quot;verdana&quot; , &quot;sans-serif&quot;; font-size: 10.0pt;\">.&nbsp;<\/span><span style=\"color: #111111; font-family: &quot;verdana&quot; , &quot;sans-serif&quot;; font-size: 10.0pt;\"><o:p><\/o:p><\/span><\/div>\n<div style=\"background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;\">\n<span style=\"border: none 1.0pt; color: #990000; font-family: &quot;verdana&quot; , &quot;sans-serif&quot;; font-size: 10.0pt; padding: 0in;\"><br \/>\n<\/span><span style=\"color: #990000; font-family: &quot;verdana&quot; , &quot;sans-serif&quot;; font-size: 10.0pt;\">Object2&nbsp;<\/span><span style=\"color: #111111; font-family: &quot;verdana&quot; , &quot;sans-serif&quot;; font-size: 10.0pt;\">it pushes to the finalization queue.<\/span><span style=\"color: #111111; font-family: &quot;verdana&quot; , &quot;sans-serif&quot;; font-size: 10.0pt;\"><o:p><\/o:p><\/span><\/div>\n<div style=\"background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;\">\n<\/div>\n<div style=\"background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;\">\n<span style=\"color: #111111; font-family: &quot;verdana&quot; , &quot;sans-serif&quot;; font-size: 10.0pt;\">Now garbage collector runs for the second time. It sees there<br \/>\nare no objects to be released and then checks for the finalization queue and at<br \/>\nthis moment, it clears&nbsp;<\/span><span style=\"color: #990000; font-family: &quot;verdana&quot; , &quot;sans-serif&quot;; font-size: 10.0pt;\">object2&nbsp;<\/span><span style=\"color: #111111; font-family: &quot;verdana&quot; , &quot;sans-serif&quot;; font-size: 10.0pt;\">from the memory.&nbsp;<\/span><span style=\"color: #111111; font-family: &quot;verdana&quot; , &quot;sans-serif&quot;; font-size: 10.0pt;\"><o:p><\/o:p><\/span><\/div>\n<div style=\"background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;\">\n<span style=\"color: #111111; font-family: &quot;verdana&quot; , &quot;sans-serif&quot;; font-size: 10.0pt;\"><br \/>\nSo if you notice,&nbsp;<\/span><span style=\"color: #990000; font-family: &quot;verdana&quot; , &quot;sans-serif&quot;; font-size: 10.0pt;\">object2&nbsp;<\/span><span style=\"color: #111111; font-family: &quot;verdana&quot; , &quot;sans-serif&quot;; font-size: 10.0pt;\">was released from memory in the second round and not<br \/>\nfirst. That is why the best practice is not to write clean up<br \/>\nnon.NET\/unmanaged&nbsp;resources in&nbsp;<\/span><span style=\"color: #990000; font-family: &quot;verdana&quot; , &quot;sans-serif&quot;; font-size: 10.0pt;\">Finalize&nbsp;<\/span><span style=\"color: #111111; font-family: &quot;verdana&quot; , &quot;sans-serif&quot;; font-size: 10.0pt;\">method rather use<br \/>\nthe&nbsp;<\/span><span style=\"color: #990000; font-family: &quot;verdana&quot; , &quot;sans-serif&quot;; font-size: 10.0pt;\">DISPOSE<\/span><span style=\"color: #111111; font-family: &quot;verdana&quot; , &quot;sans-serif&quot;; font-size: 10.0pt;\">.<\/span><span style=\"color: #111111; font-family: &quot;verdana&quot; , &quot;sans-serif&quot;; font-size: 10.0pt;\"><o:p><\/o:p><\/span><\/p>\n<p><span style=\"color: #111111; font-family: &quot;verdana&quot; , &quot;sans-serif&quot;; font-size: 10.0pt;\"><\/span><\/p>\n<div style=\"margin-bottom: .0001pt; margin: 0in;\">\n<b><span style=\"color: #111111; font-family: &quot;verdana&quot; , &quot;sans-serif&quot;; font-size: 10.0pt;\">What<br \/>\nis the purpose of the Using block in C#?<\/span><\/b><\/div>\n<div style=\"margin-bottom: .0001pt; margin: 0in;\">\n<span style=\"color: #242729; font-family: &quot;verdana&quot; , sans-serif; font-size: 10pt;\"><br \/><\/span><\/div>\n<div style=\"margin-bottom: .0001pt; margin: 0in;\">\n<span style=\"color: #242729; font-family: &quot;verdana&quot; , sans-serif; font-size: 10pt;\">The using statement allows the programmer to specify when<br \/>\nobjects that use resources should release them. The object provided to the<br \/>\nusing statement must implement the IDisposable interface. This interface<br \/>\nprovides the Dispose method, which should release the object&#8217;s resources.<\/span><\/div>\n<\/div>\n<div style=\"background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; line-height: normal; margin-bottom: 0in;\">\n<div style=\"background-color: white;\">\n<span style=\"color: #242729; font-family: &quot;verdana&quot; , sans-serif;\"><span style=\"font-size: 13.3333px;\"><br \/><\/span><\/span>\n<\/div>\n<div style=\"background-color: white; color: #111111; display: inline; font-family: verdana, sans-serif; font-size: 13.3333px; line-height: normal; text-align: left;\">\n<span style=\"font-family: &quot;verdana&quot; , &quot;sans-serif&quot;; font-size: 10.0pt;\"><o:p><\/o:p><\/span><\/div>\n<pre style=\"background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; color: #111111; font-size: 13.3333px; vertical-align: baseline;\"><span style=\"background-color: white;\"><span><span style=\"border: 1pt none; color: #101094; font-family: &quot;verdana&quot; , sans-serif; padding: 0in;\">public<\/span><\/span><span><span style=\"border: 1pt none; color: #303336; font-family: &quot;verdana&quot; , sans-serif; padding: 0in;\"><span style=\"box-sizing: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit;\"> <\/span><\/span><span><\/span><span style=\"border: 1pt none; color: #101094; font-family: &quot;verdana&quot; , sans-serif; padding: 0in;\"><span style=\"box-sizing: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit;\">class<\/span><\/span><\/span><span><span style=\"border: 1pt none; color: #303336; font-family: &quot;verdana&quot; , sans-serif; padding: 0in;\"><span style=\"box-sizing: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit;\"> <\/span><\/span><span><\/span><span style=\"border: 1pt none; color: #2b91af; font-family: &quot;verdana&quot; , sans-serif; padding: 0in;\"><span style=\"box-sizing: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit;\">Debuggersspace<\/span><\/span><span><span style=\"border: 1pt none; color: #303336; font-family: &quot;verdana&quot; , sans-serif; padding: 0in;\"> <\/span><\/span><span><\/span><span style=\"border: 1pt none; color: #303336; font-family: &quot;verdana&quot; , sans-serif; padding: 0in;\"><span style=\"box-sizing: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit;\">:<\/span><\/span><\/span><span><span style=\"border: 1pt none; color: #303336; font-family: &quot;verdana&quot; , sans-serif; padding: 0in;\"><span style=\"box-sizing: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit;\"> <\/span><\/span><span><\/span><span style=\"border: 1pt none; color: #2b91af; font-family: &quot;verdana&quot; , sans-serif; padding: 0in;\"><span style=\"box-sizing: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit;\">IDisposable<\/span><\/span><\/span><\/span><\/pre>\n<pre style=\"background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; color: #111111; font-size: 13.3333px; vertical-align: baseline;\">{<\/pre>\n<pre style=\"background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; color: #111111; font-size: 13.3333px; vertical-align: baseline;\"><span style=\"color: #111111; font-family: &quot;verdana&quot; , sans-serif; font-size: 13.3333px; font-style: inherit; font-weight: inherit;\"><span style=\"border: 1pt none; color: #303336; font-family: &quot;verdana&quot; , sans-serif; padding: 0in;\">&nbsp;\/\/<\/span><\/span><span style=\"color: #111111; font-family: &quot;verdana&quot; , sans-serif; font-size: 13.3333px; font-style: inherit; font-weight: inherit;\"><span style=\"border: 1pt none; color: #303336; font-family: &quot;verdana&quot; , sans-serif; padding: 0in;\"><span style=\"box-sizing: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit;\">implementation details<\/span><\/span><\/span><span style=\"color: #111111; font-family: &quot;verdana&quot; , sans-serif; font-size: 13.3333px; font-style: inherit; font-weight: inherit;\"><span style=\"border: 1pt none; color: #303336; font-family: &quot;verdana&quot; , sans-serif; padding: 0in;\"><span style=\"box-sizing: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit;\">...<\/span><\/span><\/span><\/pre>\n<pre style=\"background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; color: #111111; font-size: 13.3333px; vertical-align: baseline;\">}<\/pre>\n<pre style=\"background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; color: #111111; font-size: 13.3333px; vertical-align: baseline;\">\n<\/pre>\n<p><span style=\"box-sizing: inherit; color: #111111; font-size: 13.3333px; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit;\"><span style=\"box-sizing: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit;\"><span style=\"box-sizing: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit;\"><br \/>\n<\/span><\/span><\/span><\/p>\n<div style=\"font-family: verdana, sans-serif; margin: 0in 0in 12pt; vertical-align: baseline;\">\n<span style=\"box-sizing: inherit; color: #111111; font-size: 13.3333px; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit;\"><span style=\"box-sizing: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit;\"><span style=\"box-sizing: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit;\"><span style=\"background-color: white; color: #242729; font-family: &quot;verdana&quot; , &quot;sans-serif&quot;; font-size: 10pt;\">These<br \/>\nare equivalent:<\/span><\/span><\/span><\/span><br \/>\n<span style=\"box-sizing: inherit; color: #111111; font-size: 13.3333px; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit;\"><span style=\"box-sizing: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit;\"><span style=\"box-sizing: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit;\"><span style=\"font-size: 13.3333px; font-style: inherit; font-variant-caps: inherit; font-variant-ligatures: inherit; font-weight: inherit;\"><span style=\"border: 1pt none; color: #2b91af; font-family: &quot;verdana&quot; , sans-serif; padding: 0in;\"><span style=\"box-sizing: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit;\">Debuggersspace<\/span><\/span><span><span style=\"border: 1pt none; color: #303336; font-family: &quot;verdana&quot; , sans-serif; padding: 0in;\"> <\/span><span style=\"box-sizing: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit;\">qa <\/span><\/span><\/span><span style=\"font-size: 13.3333px; font-style: inherit; font-variant-caps: inherit; font-variant-ligatures: inherit; font-weight: inherit;\"><span style=\"border: 1pt none; color: #303336; font-family: &quot;verdana&quot; , sans-serif; padding: 0in;\"><span style=\"box-sizing: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit;\">=<\/span><\/span><\/span><span style=\"font-size: 13.3333px; font-style: inherit; font-variant-caps: inherit; font-variant-ligatures: inherit; font-weight: inherit;\"><span style=\"border: 1pt none; color: #303336; font-family: &quot;verdana&quot; , sans-serif; padding: 0in;\"><span style=\"box-sizing: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit;\"> <\/span><\/span><span><\/span><span style=\"border: 1pt none; color: #101094; font-family: &quot;verdana&quot; , sans-serif; padding: 0in;\"><span style=\"box-sizing: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit;\">new<\/span><\/span><\/span><span style=\"font-size: 13.3333px; font-style: inherit; font-variant-caps: inherit; font-variant-ligatures: inherit; font-weight: inherit;\"><span style=\"border: 1pt none; color: #303336; font-family: &quot;verdana&quot; , sans-serif; padding: 0in;\"><span style=\"box-sizing: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit;\"> <\/span><\/span><span><\/span><span style=\"border: 1pt none; color: #2b91af; font-family: &quot;verdana&quot; , sans-serif; padding: 0in;\"><span style=\"box-sizing: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit;\">Debuggersspace<\/span><\/span><span><span style=\"border: 1pt none; color: #303336; font-family: &quot;verdana&quot; , sans-serif; padding: 0in;\"> <\/span><\/span><span><\/span><span style=\"border: 1pt none; color: #303336; font-family: &quot;verdana&quot; , sans-serif; padding: 0in;\"><span style=\"box-sizing: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit;\">();<\/span><\/span><\/span><\/span><\/span><\/span><br \/>\n<span style=\"box-sizing: inherit; color: #111111; font-size: 13.3333px; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit;\"><span style=\"box-sizing: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit;\"><span style=\"box-sizing: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit;\"><span style=\"border: 1pt none; color: #101094; font-family: &quot;verdana&quot; , sans-serif; font-size: 13.3333px; font-style: inherit; font-weight: inherit; padding: 0in;\"><span style=\"box-sizing: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit;\">try<\/span><\/span><span style=\"font-size: 13.3333px; font-style: inherit; font-variant-caps: inherit; font-variant-ligatures: inherit; font-weight: inherit;\"><span style=\"border: 1pt none; color: #303336; font-family: &quot;verdana&quot; , sans-serif; padding: 0in;\"><span style=\"box-sizing: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit;\">&nbsp;<\/span><\/span><\/span><\/span><\/span><\/span><br \/>\n<span style=\"box-sizing: inherit; color: #111111; font-size: 13.3333px; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit;\"><span style=\"box-sizing: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit;\"><span style=\"box-sizing: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit;\"><span style=\"font-size: 13.3333px; font-style: inherit; font-variant-caps: inherit; font-variant-ligatures: inherit; font-weight: inherit;\"><span><\/span><span style=\"border: 1pt none; color: #303336; font-family: &quot;verdana&quot; , sans-serif; padding: 0in;\"><span style=\"box-sizing: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit;\">{<\/span><\/span><\/span><\/span><\/span><\/span><br \/>\n<span style=\"box-sizing: inherit; color: #111111; font-size: 13.3333px; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit;\"><span style=\"box-sizing: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit;\"><span style=\"box-sizing: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit;\"><span style=\"font-size: 13.3333px; font-style: inherit; font-variant-caps: inherit; font-variant-ligatures: inherit; font-weight: inherit;\"><span style=\"border: 1pt none; color: #303336; font-family: &quot;verdana&quot; , sans-serif; padding: 0in;\">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<\/span><span style=\"border: 1pt none; padding: 0in;\">qa<\/span><\/span><span style=\"font-size: 13.3333px; font-style: inherit; font-variant-caps: inherit; font-variant-ligatures: inherit; font-weight: inherit;\"><span style=\"border: 1pt none; color: #303336; font-family: &quot;verdana&quot; , sans-serif; padding: 0in;\"><span style=\"box-sizing: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit;\">.<\/span><\/span><\/span><span style=\"font-size: 13.3333px; font-style: inherit; font-variant-caps: inherit; font-variant-ligatures: inherit; font-weight: inherit;\"><span style=\"border: 1pt none; color: #2b91af; font-family: &quot;verdana&quot; , sans-serif; padding: 0in;\"><span style=\"box-sizing: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit;\">Action<\/span><\/span><\/span><span style=\"font-size: 13.3333px; font-style: inherit; font-variant-caps: inherit; font-variant-ligatures: inherit; font-weight: inherit;\"><span style=\"border: 1pt none; color: #303336; font-family: &quot;verdana&quot; , sans-serif; padding: 0in;\"><span style=\"box-sizing: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit;\">();<\/span><\/span><\/span><\/span><\/span><\/span><br \/>\n<span style=\"box-sizing: inherit; color: #111111; font-size: 13.3333px; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit;\"><span style=\"box-sizing: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit;\"><span style=\"box-sizing: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit;\"><span style=\"background-color: white; font-size: 13.3333px; font-style: inherit; font-variant-caps: inherit; font-variant-ligatures: inherit; font-weight: inherit;\">}<\/span><\/span><\/span><\/span><br \/>\n<span style=\"box-sizing: inherit; color: #111111; font-size: 13.3333px; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit;\"><span style=\"box-sizing: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit;\"><span style=\"box-sizing: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit;\"><span style=\"border: 1pt none; color: #101094; font-family: &quot;verdana&quot; , sans-serif; font-size: 13.3333px; font-style: inherit; font-weight: inherit; padding: 0in;\"><span style=\"box-sizing: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit;\">finally<\/span><\/span><\/span><\/span><\/span><br \/>\n<span style=\"background-color: white; color: #303336; font-size: 13.3333px; font-style: inherit; font-variant-caps: inherit; font-variant-ligatures: inherit; font-weight: inherit;\">{<\/span><br \/>\n<span style=\"box-sizing: inherit; color: #111111; font-size: 13.3333px; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit;\"><span style=\"box-sizing: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit;\"><span style=\"box-sizing: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit;\"><span style=\"font-size: 13.3333px; font-style: inherit; font-variant-caps: inherit; font-variant-ligatures: inherit; font-weight: inherit;\"><span style=\"border: 1pt none; color: #303336; font-family: &quot;verdana&quot; , sans-serif; padding: 0in;\">&nbsp; &nbsp; &nbsp; &nbsp;<\/span><\/span><span style=\"font-size: 13.3333px; font-style: inherit; font-variant-caps: inherit; font-variant-ligatures: inherit; font-weight: inherit;\"><span style=\"border: 1pt none; color: #101094; font-family: &quot;verdana&quot; , sans-serif; padding: 0in;\">if<\/span><\/span><span style=\"font-size: 13.3333px; font-style: inherit; font-variant-caps: inherit; font-variant-ligatures: inherit; font-weight: inherit;\"><span style=\"border: 1pt none; color: #303336; font-family: &quot;verdana&quot; , sans-serif; padding: 0in;\"><span style=\"box-sizing: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit;\"> <\/span><\/span><span><\/span><span style=\"border: 1pt none; color: #303336; font-family: &quot;verdana&quot; , sans-serif; padding: 0in;\"><span style=\"box-sizing: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit;\">(<\/span><\/span><\/span><span style=\"font-size: 13.3333px; font-style: inherit; font-variant-caps: inherit; font-variant-ligatures: inherit; font-weight: inherit;\"><span style=\"border: 1pt none; color: #303336; font-family: &quot;verdana&quot; , sans-serif; padding: 0in;\"><span style=\"box-sizing: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit;\">qa <\/span><\/span><\/span><span style=\"font-size: 13.3333px; font-style: inherit; font-variant-caps: inherit; font-variant-ligatures: inherit; font-weight: inherit;\"><span style=\"border: 1pt none; color: #303336; font-family: &quot;verdana&quot; , sans-serif; padding: 0in;\"><span style=\"box-sizing: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit;\">!=<\/span><\/span><\/span><span style=\"font-size: 13.3333px; font-style: inherit; font-variant-caps: inherit; font-variant-ligatures: inherit; font-weight: inherit;\"><span style=\"border: 1pt none; color: #303336; font-family: &quot;verdana&quot; , sans-serif; padding: 0in;\"><span style=\"box-sizing: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit;\"> <\/span><\/span><span><\/span><span style=\"border: 1pt none; color: #101094; font-family: &quot;verdana&quot; , sans-serif; padding: 0in;\"><span style=\"box-sizing: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit;\">null<\/span><\/span><\/span><span style=\"font-size: 13.3333px; font-style: inherit; font-variant-caps: inherit; font-variant-ligatures: inherit; font-weight: inherit;\"><span style=\"border: 1pt none; color: #303336; font-family: &quot;verdana&quot; , sans-serif; padding: 0in;\"><span style=\"box-sizing: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit;\">)<\/span><\/span><\/span><\/span><\/span><\/span><br \/>\n<span style=\"box-sizing: inherit; color: #111111; font-size: 13.3333px; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit;\"><span style=\"box-sizing: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit;\"><span style=\"box-sizing: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit;\"><span style=\"font-size: 13.3333px; font-style: inherit; font-variant-caps: inherit; font-variant-ligatures: inherit; font-weight: inherit;\"><span style=\"border: 1pt none; color: #303336; font-family: &quot;verdana&quot; , sans-serif; padding: 0in;\">&nbsp; &nbsp; &nbsp; &nbsp;qa<\/span><\/span><span style=\"font-size: 13.3333px; font-style: inherit; font-variant-caps: inherit; font-variant-ligatures: inherit; font-weight: inherit;\"><span style=\"border: 1pt none; color: #303336; font-family: &quot;verdana&quot; , sans-serif; padding: 0in;\">.<\/span><\/span><span style=\"font-size: 13.3333px; font-style: inherit; font-variant-caps: inherit; font-variant-ligatures: inherit; font-weight: inherit;\"><span style=\"border: 1pt none; color: #2b91af; font-family: &quot;verdana&quot; , sans-serif; padding: 0in;\"><span style=\"box-sizing: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit;\">Dispose<\/span><\/span><\/span><span style=\"font-size: 13.3333px; font-style: inherit; font-variant-caps: inherit; font-variant-ligatures: inherit; font-weight: inherit;\"><span style=\"border: 1pt none; color: #303336; font-family: &quot;verdana&quot; , sans-serif; padding: 0in;\"><span style=\"box-sizing: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit;\">();<\/span><\/span><\/span><\/span><\/span><\/span><br \/>\n<span style=\"box-sizing: inherit; color: #111111; font-size: 13.3333px; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit;\"><span style=\"box-sizing: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit;\"><span style=\"box-sizing: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit;\"><span style=\"background-color: white; color: #303336; font-size: 13.3333px; font-style: inherit; font-weight: inherit;\">}<\/span><\/span><\/span><\/span><br \/>\n<span style=\"box-sizing: inherit; color: #111111; font-size: 13.3333px; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit;\"><span style=\"box-sizing: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit;\"><span style=\"box-sizing: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit;\"><span style=\"background-color: white; color: #303336; font-size: 13.3333px; font-style: inherit; font-weight: inherit;\"><br \/><\/span><\/span><\/span><\/span><br \/>\n<span style=\"box-sizing: inherit; color: #111111; font-size: 13.3333px; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit;\"><span style=\"box-sizing: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit;\"><span style=\"box-sizing: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit;\"><span style=\"background-color: white; color: #303336; font-size: 13.3333px; font-style: inherit; font-weight: inherit;\"><span style=\"color: #242729; font-family: &quot;verdana&quot; , sans-serif; font-size: 10pt;\">In other words, the&nbsp;<\/span><code style=\"box-sizing: inherit; color: #111111; font-size: 13.3333px; font-stretch: inherit; line-height: inherit; white-space: pre-wrap;\"><span style=\"background: rgb(239, 240, 241); border: 1pt none; color: #242729; font-family: &quot;verdana&quot; , sans-serif; font-size: 10pt; padding: 0in;\">using<\/span><\/code><span style=\"color: #242729; font-family: &quot;verdana&quot; , sans-serif; font-size: 10pt;\">&nbsp;statement tells .NET to release the object specified in the&nbsp;<\/span><code style=\"box-sizing: inherit; color: #111111; font-size: 13.3333px; font-stretch: inherit; line-height: inherit; white-space: pre-wrap;\"><span style=\"background: rgb(239, 240, 241); border: 1pt none; color: #242729; font-family: &quot;verdana&quot; , sans-serif; font-size: 10pt; padding: 0in;\">using<\/span><\/code><span style=\"color: #242729; font-family: &quot;verdana&quot; , sans-serif; font-size: 10pt;\">&nbsp;block once it is no longer needed<\/span><\/span><\/span><\/span><\/span><br \/>\n<span style=\"box-sizing: inherit; color: #111111; font-size: 13.3333px; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit;\"><span style=\"box-sizing: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit;\"><span style=\"box-sizing: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit;\"><span style=\"background-color: white; color: #303336; font-size: 13.3333px; font-style: inherit; font-weight: inherit;\"><span style=\"color: #242729; font-family: &quot;verdana&quot; , sans-serif; font-size: 10pt;\"><br \/><\/span><\/span><\/span><\/span><\/span><br \/>\n<span style=\"box-sizing: inherit; color: #111111; font-size: 13.3333px; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit;\"><span style=\"box-sizing: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit;\"><span style=\"box-sizing: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit;\"><span style=\"font-size: 13.3333px; font-style: inherit; font-variant-caps: inherit; font-variant-ligatures: inherit; font-weight: inherit;\"><span style=\"border: 1pt none; color: #303336; font-family: &quot;verdana&quot; , sans-serif; padding: 0in;\"><span style=\"box-sizing: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit;\">using <\/span><\/span><\/span><span style=\"font-size: 13.3333px; font-style: inherit; font-variant-caps: inherit; font-variant-ligatures: inherit; font-weight: inherit;\"><span style=\"border: 1pt none; color: #303336; font-family: &quot;verdana&quot; , sans-serif; padding: 0in;\"><span style=\"box-sizing: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit;\">(<\/span><\/span><\/span><span style=\"font-size: 13.3333px; font-style: inherit; font-variant-caps: inherit; font-variant-ligatures: inherit; font-weight: inherit;\"><span style=\"border: 1pt none; color: #2b91af; font-family: &quot;verdana&quot; , sans-serif; padding: 0in;\"><span style=\"box-sizing: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit;\">Debuggersspace<\/span><\/span><span><span style=\"border: 1pt none; color: #303336; font-family: &quot;verdana&quot; , sans-serif; padding: 0in;\"> <\/span><span style=\"box-sizing: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit;\">qa <\/span><\/span><\/span><span style=\"font-size: 13.3333px; font-style: inherit; font-variant-caps: inherit; font-variant-ligatures: inherit; font-weight: inherit;\"><span style=\"border: 1pt none; color: #303336; font-family: &quot;verdana&quot; , sans-serif; padding: 0in;\"><span style=\"box-sizing: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit;\">=<\/span><\/span><\/span><span style=\"font-size: 13.3333px; font-style: inherit; font-variant-caps: inherit; font-variant-ligatures: inherit; font-weight: inherit;\"><span style=\"border: 1pt none; color: #303336; font-family: &quot;verdana&quot; , sans-serif; padding: 0in;\"><span style=\"box-sizing: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit;\"> <\/span><\/span><span><\/span><span style=\"border: 1pt none; color: #101094; font-family: &quot;verdana&quot; , sans-serif; padding: 0in;\"><span style=\"box-sizing: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit;\">new<\/span><\/span><\/span><span style=\"font-size: 13.3333px; font-style: inherit; font-variant-caps: inherit; font-variant-ligatures: inherit; font-weight: inherit;\"><span style=\"border: 1pt none; color: #303336; font-family: &quot;verdana&quot; , sans-serif; padding: 0in;\"><span style=\"box-sizing: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit;\"> <\/span><\/span><span><\/span><span style=\"border: 1pt none; color: #2b91af; font-family: &quot;verdana&quot; , sans-serif; padding: 0in;\"><span style=\"box-sizing: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit;\">Debuggersspace<\/span><\/span><span><span style=\"border: 1pt none; color: #303336; font-family: &quot;verdana&quot; , sans-serif; padding: 0in;\"> <\/span><\/span><span><\/span><span style=\"border: 1pt none; color: #303336; font-family: &quot;verdana&quot; , sans-serif; padding: 0in;\"><span style=\"box-sizing: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit;\">())<\/span><\/span><\/span><\/span><\/span><\/span><br \/>\n<span style=\"box-sizing: inherit; color: #111111; font-size: 13.3333px; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit;\"><span style=\"box-sizing: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit;\"><span style=\"box-sizing: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit;\"><span style=\"background-color: white; color: #303336; font-size: 13.3333px; font-style: inherit; font-weight: inherit;\">{<\/span><\/span><\/span><\/span><br \/>\n<span style=\"box-sizing: inherit; color: #111111; font-size: 13.3333px; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit;\"><span style=\"box-sizing: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit;\"><span style=\"box-sizing: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit;\"><span style=\"font-size: 13.3333px; font-style: inherit; font-variant-caps: inherit; font-variant-ligatures: inherit; font-weight: inherit;\"><span style=\"border: 1pt none; color: #303336; font-family: &quot;verdana&quot; , sans-serif; padding: 0in;\">&nbsp; &nbsp;&nbsp;<\/span><span style=\"box-sizing: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit;\">qa<\/span><\/span><span style=\"font-size: 13.3333px; font-style: inherit; font-variant-caps: inherit; font-variant-ligatures: inherit; font-weight: inherit;\"><span style=\"border: 1pt none; color: #303336; font-family: &quot;verdana&quot; , sans-serif; padding: 0in;\">.<\/span><\/span><span style=\"font-size: 13.3333px; font-style: inherit; font-variant-caps: inherit; font-variant-ligatures: inherit; font-weight: inherit;\"><span style=\"border: 1pt none; color: #2b91af; font-family: &quot;verdana&quot; , sans-serif; padding: 0in;\"><span style=\"box-sizing: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit;\">Action<\/span><\/span><\/span><span style=\"font-size: 13.3333px; font-style: inherit; font-variant-caps: inherit; font-variant-ligatures: inherit; font-weight: inherit;\"><span style=\"border: 1pt none; color: #303336; font-family: &quot;verdana&quot; , sans-serif; padding: 0in;\"><span style=\"box-sizing: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit;\">();<\/span><\/span><\/span><span style=\"background-color: white; font-size: 13.3333px; font-style: inherit; font-variant-caps: inherit; font-variant-ligatures: inherit; font-weight: inherit;\">&nbsp;<\/span><\/span><\/span><\/span><br \/>\n<span style=\"box-sizing: inherit; color: #111111; font-size: 13.3333px; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit;\"><span style=\"box-sizing: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit;\"><span style=\"box-sizing: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit;\"><span style=\"background-color: white; color: #303336; font-size: 13.3333px; font-style: inherit; font-weight: inherit;\">}<\/span><\/span><\/span><\/span><\/div>\n<p><span style=\"box-sizing: inherit; color: #111111; font-size: 13.3333px; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit;\"><span style=\"box-sizing: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit;\"><span style=\"box-sizing: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit;\"><span style=\"box-sizing: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit;\"><span style=\"box-sizing: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit;\"><span style=\"box-sizing: inherit; font-family: &quot;verdana&quot; , sans-serif; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit;\"><span style=\"box-sizing: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit;\"><span style=\"box-sizing: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit;\"><span style=\"box-sizing: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit;\"><\/p>\n<div style=\"background-color: white; line-height: normal; margin-bottom: 0.0001pt;\">\n<span style=\"color: black; font-family: &quot;verdana&quot; , &quot;sans-serif&quot;; font-size: 10.0pt;\">Points to remember:<\/span><\/div>\n<div style=\"background-color: white; line-height: normal; margin-bottom: 0.0001pt;\">\n<\/div>\n<ol style=\"background-color: white; text-align: left;\">\n<li><span style=\"color: #242729; font-family: &quot;verdana&quot; , sans-serif; font-size: 10pt; font-style: inherit; font-weight: inherit; text-indent: -0.25in;\">If you declare the<br \/>\nvariable outside the using block and then create a new instance in the using<br \/>\nstatement it may not dispose the item<\/span><\/li>\n<li><span style=\"color: #242729; font-family: &quot;verdana&quot; , sans-serif; font-size: 10pt; font-style: inherit; font-weight: inherit; text-indent: -0.25in;\">So the using<br \/>\nstatement will automatically dispose of the object once that context is complete.<\/span><\/li>\n<li>The using statement<br \/>\nis used to work with an object in C# that implements the&nbsp;<code style=\"box-sizing: inherit; font-size: 13.3333px; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; text-indent: -0.25in; white-space: pre-wrap;\"><span style=\"background: #eff0f1; border: none 1.0pt; color: #242729; font-family: &quot;verdana&quot; , &quot;sans-serif&quot;; font-size: 10.0pt; padding: 0in;\">IDisposable<\/span><\/code><span style=\"color: #242729; font-family: &quot;verdana&quot; , sans-serif; font-size: 10pt; font-style: inherit; font-weight: inherit; text-indent: -0.25in;\">interface.<\/span><\/li>\n<li>The&nbsp;<code style=\"box-sizing: inherit; font-size: 13.3333px; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; text-indent: -0.25in; white-space: pre-wrap;\"><span style=\"background: #eff0f1; border: none 1.0pt; color: #242729; font-family: &quot;verdana&quot; , &quot;sans-serif&quot;; font-size: 10.0pt; padding: 0in;\">IDisposable<\/span><\/code><span style=\"color: #242729; font-family: &quot;verdana&quot; , sans-serif; font-size: 10pt; font-style: inherit; font-weight: inherit; text-indent: -0.25in;\">&nbsp;interface has one public method called&nbsp;<\/span><code style=\"box-sizing: inherit; font-size: 13.3333px; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; text-indent: -0.25in; white-space: pre-wrap;\"><span style=\"background: #eff0f1; border: none 1.0pt; color: #242729; font-family: &quot;verdana&quot; , &quot;sans-serif&quot;; font-size: 10.0pt; padding: 0in;\">Dispose<\/span><\/code><span style=\"color: #242729; font-family: &quot;verdana&quot; , sans-serif; font-size: 10pt; font-style: inherit; font-weight: inherit; text-indent: -0.25in;\">&nbsp;that is used to dispose of the object.<\/span><\/li>\n<li>we use the using<br \/>\nstatement, we don&#8217;t need to explicitly dispose of the object in the code, the<br \/>\nusing statement takes care of it.<\/li>\n<\/ol>\n<p><\/span><\/span><\/span><\/span><\/span><\/span><\/span><\/span><\/span><span style=\"background-color: white; color: #111111; font-family: &quot;verdana&quot; , &quot;sans-serif&quot;; font-size: 10pt;\"><br \/><\/span><br \/>\n<\/p>\n<div style=\"background-color: white;\">\n<\/div>\n<h1 style=\"background-color: white; border: 0px; font-family: roboto, arial, sans-serif; font-weight: 400; line-height: 2.4rem; margin: 0px; max-height: 4.8rem; overflow: hidden; padding: 0px;\">\n<div style=\"line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-outline-level: 1;\">\n<b><span style=\"color: #111111; font-family: &quot;verdana&quot; , &quot;sans-serif&quot;; font-size: 10.0pt;\">C# Disposable pattern, Using, Dispose Vs Finalize:<o:p><\/o:p><\/span><\/b><\/div>\n<\/h1>\n<div style=\"background-color: white;\">\n<span style=\"color: #111111; font-family: &quot;verdana&quot; , &quot;sans-serif&quot;; font-size: 10.0pt;\"><br \/><\/span><\/div>\n<\/div>\n<div style=\"background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;\">\n<div style=\"clear: both; text-align: center;\">\n<iframe loading=\"lazy\" allowfullscreen=\"\" data-thumbnail-src=\"https:\/\/i.ytimg.com\/vi\/cZtgIwHLJmc\/0.jpg\" frameborder=\"0\" height=\"366\" src=\"https:\/\/www.youtube.com\/embed\/cZtgIwHLJmc?feature=player_embedded\" width=\"600\"><\/iframe><\/div>\n<p><span style=\"color: #111111; font-family: &quot;verdana&quot; , &quot;sans-serif&quot;; font-size: 10.0pt;\"><br style=\"mso-special-character: line-break;\" \/><br \/>\n<!--[if !supportLineBreakNewLine]--><br style=\"mso-special-character: line-break;\" \/><br \/>\n<!--[endif]--><\/span><span style=\"color: black; font-family: &quot;verdana&quot; , &quot;sans-serif&quot;; font-size: 10.0pt;\"><o:p><\/o:p><\/span><\/div>\n<div style=\"background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;\">\n<b><span style=\"color: #111111; font-family: &quot;verdana&quot; , &quot;sans-serif&quot;; font-size: 10.0pt;\">Please refer below links for more information:<\/span><\/b><span style=\"color: #111111; font-family: &quot;verdana&quot; , &quot;sans-serif&quot;; font-size: 10.0pt;\"><o:p><\/o:p><\/span><\/div>\n<div style=\"background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;\">\n<\/div>\n<div style=\"background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;\">\n<span style=\"color: #111111; font-family: &quot;verdana&quot; , &quot;sans-serif&quot;; font-size: 10.0pt;\"><a href=\"https:\/\/www.c-sharpcorner.com\/UploadFile\/nityaprakash\/back-to-basics-dispose-vs-finalize\/\" target=\"_blank\" rel=\"noopener\">https:\/\/www.c-sharpcorner.com\/UploadFile\/nityaprakash\/back-to-basics-dispose-vs-finalize\/&nbsp;<\/a>&nbsp;<\/span><span style=\"color: black; font-family: &quot;verdana&quot; , &quot;sans-serif&quot;; font-size: 10.0pt;\"><o:p><\/o:p><\/span><\/div>\n<div>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>.NET Framework provides two methods Finalize and Dispose for releasing unmanaged resources like:&nbsp;Windows API created objects, File, Database connection objects, COM objects. It is always recommended to use Dispose method to clean unmanaged resources. Do not implement the Finalize method until it is extremely necessary Dispose: Dispose&nbsp;method belongs to \u2018IDisposable\u2019 interface. If any object wants [&hellip;]<\/p>\n","protected":false},"author":43,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_uag_custom_page_level_css":"","footnotes":""},"categories":[24],"tags":[],"class_list":["post-63","post","type-post","status-publish","format-standard","hentry","category-c-net"],"uagb_featured_image_src":{"full":false,"thumbnail":false,"medium":false,"medium_large":false,"large":false,"1536x1536":false,"2048x2048":false},"uagb_author_info":{"display_name":"Himanshu Namdeo","author_link":"https:\/\/debuggersspace.com\/author\/admin\/"},"uagb_comment_info":0,"uagb_excerpt":".NET Framework provides two methods Finalize and Dispose for releasing unmanaged resources like:&nbsp;Windows API created objects, File, Database connection objects, COM objects. It is always recommended to use Dispose method to clean unmanaged resources. Do not implement the Finalize method until it is extremely necessary Dispose: Dispose&nbsp;method belongs to \u2018IDisposable\u2019 interface. If any object wants&hellip;","_links":{"self":[{"href":"https:\/\/debuggersspace.com\/index.php\/wp-json\/wp\/v2\/posts\/63"}],"collection":[{"href":"https:\/\/debuggersspace.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/debuggersspace.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/debuggersspace.com\/index.php\/wp-json\/wp\/v2\/users\/43"}],"replies":[{"embeddable":true,"href":"https:\/\/debuggersspace.com\/index.php\/wp-json\/wp\/v2\/comments?post=63"}],"version-history":[{"count":0,"href":"https:\/\/debuggersspace.com\/index.php\/wp-json\/wp\/v2\/posts\/63\/revisions"}],"wp:attachment":[{"href":"https:\/\/debuggersspace.com\/index.php\/wp-json\/wp\/v2\/media?parent=63"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/debuggersspace.com\/index.php\/wp-json\/wp\/v2\/categories?post=63"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/debuggersspace.com\/index.php\/wp-json\/wp\/v2\/tags?post=63"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}