Home »
VB.Net »
VB.Net Programs
VB.Net program to demonstrate the boxing
By Nidhi Last Updated : November 11, 2024
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 »