PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197
What is __BOXED how to translate to VB?-VBForums
Results 1 to 4 of 4

Thread: What is __BOXED how to translate to VB?

  1. #1

    Thread Starter
    King of sapila
    Join Date
    Oct 2006
    Location
    Greece
    Posts
    5,380

    What is __BOXED how to translate to VB?

    HI.
    I am decompiling some code and I see this:
    __Boxed<RequestStatus> local = (System.Enum) RequestStatus.Completed;

    From what I've read it is just a type passed to a variable?
    So I just do this:
    Dim local = CType(RequestStatus.Completed, System.[Enum])

    Is this correct?
    I do not see anything on google specific for __Boxed , or it is just a decompiler thing?
    Thanks.
    Slow as hell.

  2. #2
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    100,375

    Re: What is __BOXED how to translate to VB?

    Boxing is the act of wrapping a value in an object. For instance:
    vb.net Code:
    1. Dom number As Object = 100
    100 is an Integer literal and Integer is a value type, so it would normally be stored on the stack. Because the variable is type Object though, a reference to an object stored on the heap will be created. If you wee to cast that Object reference as type Integer then you would be unboxing the value.

    In your case, RequestStatus is presumably an enumeration and they are value types but it is being cast as type System.Enum, which is a class, i.e. a reference type. That means that, again, a value type that would normally be stored on the stack is being stored on the heap and referenced. That __Boxed<T> is presumably a system type that is intended specifically to be used to refer to boxed values. The code you posted will indeed produce a boxed value but I expect that you can't ever access that __Boxed<T> type yourself.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    100,375

    Re: What is __BOXED how to translate to VB?

    I guess the question is why you need to box that value. The fact that it is done in that code doesn't necessarily mean that it is necessary.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  4. #4

    Thread Starter
    King of sapila
    Join Date
    Oct 2006
    Location
    Greece
    Posts
    5,380

    Re: What is __BOXED how to translate to VB?

    Hey.
    Yes I guess that was a decompiling engine call, so I will not take in consideration but good to know.
    Thanks.
    Slow as hell.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width