Here, an integer variable is created and box by assigning the value of the integer variable to the variable of the type of object.Program :
The source code for the boxing demonstration is given below. The program given is compiled and successfully executed.
'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
We built a Module1 module in the above program that contains a subroutine Main(). The subroutine Main() is an entry point for the program. We created an integer type variable here and then boxed it by adding an integer variable value to an object type variable on the console screen.