×

VB.Net Programs

VB.Net program to demonstrate the un-boxing

By Nidhi Last Updated : November 14, 2024

Un-boxing Example in VB.Net

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

Program/Source Code:

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

VB.Net code to demonstrate the example of un-boxing

'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
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 obj of object type and then perform un-boxing by assigning the value of an object to the integer variable after converting from Cint() function, and that on the console screen.

VB.Net Basic Programs »


Comments and Discussions!

Load comments ↻





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