Boxing/unboxing

  • Thread starter Thread starter Jonathan Lurie
  • Start date Start date
J

Jonathan Lurie

Hi
Suppose I have a function with object type parameter.

Function DoSomething(ByVal obj As Object) As Double
Return obj + 100
End Function

DoSomething(5)


I want to know when does the Boxing/unboxing takes place. Is it:
1. While receiving the value
2. or While using the object value. (Return obj + 100)

John
 
Jonathan,
I want to know when does the Boxing/unboxing takes place.

An easy way to find out is to compile the code, open the executable in
Ildasm.exe and look for box and unbox instructions.

1. While receiving the value
2. or While using the object value. (Return obj + 100)

#2 for unboxing of the argument.


Mattias
 
when you are passing value 5 in method it is when it is converting the 5 to
object (busing)
 
Back
Top