System.IO.BinaryReader.Dispose C# (CSharp) Method

Dispose() protected method

protected Dispose ( bool disposing ) : void
disposing bool
return void
        protected virtual void Dispose(bool disposing)
        {
            if (disposing)
            {
                Stream copyOfStream = _stream;
                _stream = null;
                if (copyOfStream != null && !_leaveOpen)
                {
                    copyOfStream.Dispose();
                }
            }
            _stream = null;
            _buffer = null;
            _decoder = null;
            _charBytes = null;
            _singleChar = null;
            _charBuffer = null;
        }

Same methods

BinaryReader::Dispose ( ) : void

Usage Example

Example #1
0
 public void BinaryReader_DisposeTests()
 {
     // Disposing multiple times should not throw an exception
     using (Stream memStream = CreateStream())
     using (BinaryReader binaryReader = new BinaryReader(memStream))
     {
         binaryReader.Dispose();
         binaryReader.Dispose();
         binaryReader.Dispose();
     }
 }
All Usage Examples Of System.IO.BinaryReader::Dispose