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 8594265
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T00:09:28+00:00 2026-06-12T00:09:28+00:00

I was reading about the ValueType class and I am wondering if, when something

  • 0

I was reading about the ValueType class and I am wondering if, when something gets casted to a ValueType, whether it is getting boxed? Example:

void DoSomething(ValueType valueType)
{
}

DoSomething(5);

Did the int represented by the literal 5 get boxed when received by DoSomething method?

  • 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-06-12T00:09:29+00:00Added an answer on June 12, 2026 at 12:09 am

    Yes, it gets boxed.

    Think about it… for the value not to get boxed there should be some common binary representation that can be any value type – including all built in ones and any struct you may define in the future.

    Since such a binary representation doesn’t exist the value must be boxed.

    Explanation:

    When you call a method with parameters the caller places a sequence of bits at an agreed about location and in an agreed about format, for example an int is 32bits with negative numbers encoded as 1-complement, a double is 64bits encoded in IEEE floating point format, etc.

    You can’t have one method that can except both unboxed int and double because it wouldn’t know how many bits to read and how to decode themץ

    If you do want a method to accept both you can give the function the memory location of the value (the location itself is of known size and format so the method knows how to decode it) and some meta data so the method knows the actual type of the value – wrapping the value with metadata and providing it’s memory location is called (surprise, surprise) “boxing”

    So, anytime you pass a value using a parameter/variable/whatever that is not the exact type the system has to box the value or the receiver wouldn’t know much memory the value really uses and how to decode that memory from a sequence of bits back to a number or structure.

    This only applies to value types because reference types are always passed by using the memory location (the memory location is called a “reference” in .net).

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

Sidebar

Related Questions

Reading about Kohana templates and saw something I've never seen before: $this->template->title = __('Welcome
While reading about constant interface antipattern, i found final constant class with no instances
After reading about the System.Diagnostics.Contracts.Contract static class that has been influenced by the awesomeness
When reading about SQL I've come across the term 'slot'. For example, in a
while reading about declare construct from php manual i tried the following example using
I am reading about HibernateTemplate class in Spring3. Here i saw two methods update
When reading about SQL Injection and XSS i was wondering if you guys have
Reading about TFS' MSF for Agile Software Development v5.0 template ( for example here
After reading about Firefox's Geolocation functionality, which doesn't use GPS , I'm wondering what
Reading about the Dispose pattern , I see the documentation repeatedly refer to cleaning

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.