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

  • Home
  • SEARCH
  • 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 6387795
In Process

The Archive Base Latest Questions

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

If I assign a simple value type (e.g. an int) to an attribute of

  • 0

If I assign a simple value type (e.g. an int) to an attribute of type ValueType, is the value then boxed?

For example if I do this:

int i = 4;
ValueType test = i;

Will the value be boxed?

  • 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-25T03:11:49+00:00Added an answer on May 25, 2026 at 3:11 am

    Yes, it will. This is because each type occupies a constant amount of memory at runtime (int takes 4 bytes, for example). A struct will take as much space is required to lay out all of the fields in memory.

    Since you can store any value type in ValueType, and since ValueType would have to be exactly the same size as the type you’re assigning to test, the ValueType type is actually a reference type.

    Consider:

    int a = 0;
    long b = 1;
    
    ValueType test;
    
    test = a;
    test = b;
    

    This is perfectly valid code. test must occupy a fixed size on the stack, and a and b are different sizes. Hopefully this clarifies why exactly ValueType cannot itself be a value type. (It’s related to the reason why you can’t derive value types.)

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

Sidebar

Related Questions

Is there a simple attribute or data contract that I can assign to a
I have a simple record type. I allocate an new instance of this record
Alright, I have some data that I need to assign an int type identifier
A struct is a value type, so if I assign a struct to another
This should be pretty simple but for some reason I can't get this value
I have a simple object that allows you to assign three properties (x,y,z) (lets
I write a simple piece of code that creates a div and assign it
I simply try to assign a background color to each div. it looks simple
I want to assign the decimal variable "trans" to the double variable "this.Opacity". decimal
I'm sure this is simple to do but I'm struggling to get this work,

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.