VB.Net program to return an object of the class from the user-defined function

This article will be very useful if you are going to know what is the reason for it through this article VB.Net program to return an object of the class from the user-defined function We are going to know very clearly about this.

VB.Net program to return an object of the class from the user-defined function

VB.Net program to return an object of the class from the user-defined function

'VB.Net program to return an object of the class 
'from a user defined function.

Module Module1
    Class Cls
        Public num1 As Integer
        Public num2 As Integer
    End Class


    Function GetObject() As Cls
        Dim M As New Cls

        M.num1 = 10
        M.num2 = 20

        Return M
    End Function

    Sub Main()
        Dim str As New Cls

        str = GetObject()

        Console.WriteLine("Member of class are:")
        Console.WriteLine("Num1: {0}", str.num1)
        Console.WriteLine("Num2: {0}", str.num2)
    End Sub

End Module
Member of class are:
Num1: 10
Num2: 20
Press any key to continue . . .

Final Words

We hope you find the VB.Net program to return an object of the class from the user-defined function. What to do if there are any issues with this article? Then ask through the comment section.

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

Share on:

Leave a Comment