VB.Net Program to Demonstrate the Default or No-Argument Constructor

You are currently viewing VB.Net Program to Demonstrate the Default or No-Argument Constructor

VB.Net program to demonstrate the default or no-argument constructor

'VB.net program to demonstrate the 
'default or no-argument constructor.

Module Module1
    Class Sample
        Private num As Integer

        Public Sub New()
            Console.WriteLine("Default constructor called to initialize data members")
            num = 10
        End Sub

        Public Sub Print()
            Console.WriteLine("Value of num: {0}", num)
        End Sub

    End Class
    Sub Main()
        Dim obj As New Sample()
        obj.Print()
    End Sub
End Module

Output

Default constructor called to initialize data members
Value of num: 10
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