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)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top