Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6017887
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T03:11:39+00:00 2026-05-23T03:11:39+00:00

Are 2 and 3 boxing/unboxing examples? 1) The documentation example: int i = 123;

  • 0

Are 2 and 3 boxing/unboxing examples?

1) The documentation example:

int i = 123;
object iBoxed = i;
i = (int) iBoxed;

2: Is the boxing/unboxing as well?

int i = 123;
object iBoxed = i;
i = Int32.Parse(iBoxed.ToString());

3: Is the boxing/unboxing as well?

int i = 123;
object iBoxed = i;
i = Convert.ToInt32(iBoxed);

I assume that in all examples technically happens the same.

  1. A value type is created on the stack
  2. A reference is created on the stack, the value is copied to the heap.
  3. The heap value is copied to the reference. The reference gets deleted.

So I guess 2 und 3 are examples for boxing/unboxing?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T03:11:40+00:00Added an answer on May 23, 2026 at 3:11 am

    In all three examples:

    iBoxed is a boxed copy of i.

    In example 2:
    There is no unboxing involved here, as ToString is a virtual method that will finally resolve to int.ToString, which will then be parsed by int.Parse, returning a non-boxed int on the stack.

    In example 3:
    iBoxed will get unboxed in the body of the method Convert.ToInt32 and returned as a non-boxed integer, on the stack again.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I understand that boxing and unboxing is about casting (real type to object... object
I'm having a hard time understanding when to use Object (boxing/unboxing) vs when to
Since Java 5, we've had boxing/unboxing of primitive types so that int is wrapped
Extract from CLR via C# on Boxing / Unboxing value types ... On Boxing:
When using var to declare variables in C#, is there boxing/unboxing taking place? Also
Usually the compiler generates code to perform boxing and unboxing. But what does the
So I understand what boxing and unboxing is. When's it come up in real-world
I am little bit confused in boxing and unboxing. According to its definition Boxing
Does boxing/unboxing occur when a method accepts an out/ref parameter of a ValueType?
In WPF do DependencyProperty's cause lots of boxing/unboxing when used with value types? Or

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.