Home >>VB.Net Built-in Functions >VB.Net program to demonstrate the un-boxing

VB.Net program to demonstrate the un-boxing

Write a VB.Net program to demonstrate the un-boxing

Here, after converting from the Cint() function, we can create an object type variable and then perform un-boxing by assigning the object value to the integer variable.

Program :

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

'VB.Net program to demonstrate the un-boxing.


Module Module1
    Sub Main()
        Dim val As Integer
        Dim obj As Object = 10
        val = CInt(obj)
        Console.WriteLine("value of val : " & val)
    End Sub
End Module
	
Output:
value of val : 10
Explanation:

We built a Module1 module in the above program that contains a subroutine Main(). The subroutine Main() is an entry point for the program. Here, we created an object-type variable object and then un-boxed it by assigning the value of an object to an integer variable after the Cint() function has been converted to the console screen.


No Sidebar ads