VB.Net program to demonstrate the boxing

Here, we are going to demonstrate the boxing in VB.Net.
Submitted by Nidhi, on December 20, 2020 [Last updated : March 06, 2023]

Boxing Example in VB.Net

Here, we will create a variable of integer type and then perform boxing by assigned the value of integer variable to the variable of the Object type.

Program/Source Code:

The source code to demonstrate the boxing is given below. The given program is compiled and executed successfully.

VB.Net code to demonstrate the example of boxing

'VB.Net program to demonstrate the boxing.

Module Module1
    Sub Main()

        Dim val As Integer = 10
        Dim obj As Object

        obj = val
        Console.WriteLine("value of obj object : " & obj)
    End Sub
End Module

Output:

value of obj object : 10
Press any key to continue . . .

Explanation:

In the above program, we created a module Module1 that contains a Main() subroutine.

The Main() subroutine is the entry point for the program. Here we created a variable of integer type and then perform boxing by assigned the value of integer variable to the variable of the Object type, and that on the console screen.

VB.Net Basic Programs »






Comments and Discussions!

Load comments ↻






Copyright © 2024 www.includehelp.com. All rights reserved.