Using intrinsic memory management with C#
Consider the following code snippet // Declare the reader.SqlDataReader reader = null;// Use the reader here.try{ // Create the reader. reader = new SqlDataReader(…); // Use the reader.}catch{}finally{ // Check the reader for null. If it is not, then // dispose. if (reader != null) { // Dispose of it. ((IDisposable) reader).Dispose(); }} Here, we are checking whether the reader is disposed or not. If […]