Colleagues,
Subject line says it. The code:
And later, within the same Sub:
Here's the screenshot:
And now the question:
From what I read, Using statement is supposed to discard the object after the code block is executed (
What am I missing/misinterpreting?
Additionally: since TextReader is IDisposable, and StreamReader "implements" (?) TextReader ( shan't StreamReader be also IDisposable?
Please advise.
TIA!
Regards,
Ilya
Subject line says it. The code:
Code:
Dim lcBuffer(13) As Char, lcHdrStr As String
Using loStreamReader As StreamReader = New StreamReader(tcFileIn)
loStreamReader.Read(lcBuffer, 0, 14)
lcHdrStr = String.Join("", lcBuffer)
End Using
And later, within the same Sub:
Code:
Dim loStreamReader As New StreamReader(tcFileIn)
Here's the screenshot:
And now the question:
From what I read, Using statement is supposed to discard the object after the code block is executed (
https://docs.microsoft.com/en-us/dotnet/visual-basic/language-reference/statements/using-statement).
Hence me declaring loXMLStreamReader again - which generates this error.What am I missing/misinterpreting?
Additionally: since TextReader is IDisposable, and StreamReader "implements" (?) TextReader ( shan't StreamReader be also IDisposable?
Please advise.
TIA!
Regards,
Ilya