VB.net Program to Demonstrate the Objectdisposedexception

You are currently viewing VB.net Program to Demonstrate the Objectdisposedexception

VB.Net program to demonstrate the ObjectDisposedException

'Vb.Net program demonstrate the 
'ObjectDisposedException.

Imports System.IO

Module Module1
    Sub Main()
        Try
            Dim memstream As New MemoryStream(10)
            memstream.Close()

            memstream.ReadByte()
        Catch ex As ObjectDisposedException
            Console.WriteLine("Exception: " & ex.Message)
        End Try
    End Sub
End Module
Exception: Stream does not support writing.
Press any key to continue . . .

Ranjith Kumar

Hi, I'm Ranjith a full-time Blogger, YouTuber, Affiliate Marketer, & founder of Coding Diksha. Here, I post about programming to help developers.

Leave a Reply