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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T00:09:34+00:00 2026-05-11T00:09:34+00:00

Quoting from the MSDN Link for ValueType Class In cases where it is necessary

  • 0

Quoting from the MSDN Link for ValueType Class

In cases where it is necessary for a value type to behave like an object, a wrapper that makes the value type look like a reference object is allocated on the heap, and the value type’s value is copied into it. The wrapper is marked so the system knows that it contains a value type.

This means when I code like "integerVariable.ToString();" a wrapper-object created allows using this method and similarly all the other methods of System.Object.

Is this understanding correct?

How are these objects different from the ‘regular’ objects?

Is the Garbage Collection different for such object? If yes, how?

Thanks in advance.

  • 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. 2026-05-11T00:09:35+00:00Added an answer on May 11, 2026 at 12:09 am

    The wrapper is a ‘box’; re garbage collection of boxes – there is no difference as far as the grabage collector is concerned. A box is collected with exactly the same rules and treatment as any other object.

    however, if a value-type overrides a method (such as ToString()), it is not necessary to box it to call the method. Hence, value-types should (as a matter of routine) override as many of the object methods as possible ;-p

    You can see the difference in the IL (via reflector) – so for the C#:

    static int GetInteger() {return 123;} static string TestToString() {     int i = GetInteger(); // to prove no cheating     return i.ToString(); } static Type TestGetType() {     int i = GetInteger(); // to prove no cheating     return i.GetType(); } 

    We have the IL:

    .method private hidebysig static string TestToString() cil managed {     .maxstack 1     .locals init (         [0] int32 i)     L_0000: call int32 Program::GetInteger()     L_0005: stloc.0      L_0006: ldloca.s i     L_0008: call instance string [mscorlib]System.Int32::ToString()     L_000d: ret  }  .method private hidebysig static class [mscorlib]System.Type TestGetType() cil managed {     .maxstack 1     .locals init (         [0] int32 i)     L_0000: call int32 Program::GetInteger()     L_0005: stloc.0      L_0006: ldloc.0      L_0007: box int32     L_000c: call instance class [mscorlib]System.Type [mscorlib]System.Object::GetType()     L_0011: ret  } 

    Note that ToString() doesn’t involve a box, but GetType() does at L_0007 (since it isn’t (can’t be) overridden)

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

Sidebar

Related Questions

Quoting from the cakephp Book (ver 1.3): Note that only fields of the model
Quoting from Perl::Critic::Policy::InputOutput::ProhibitExplicitStdin Perl has a useful magic filehandle called *ARGV that checks the
For some reasons, I would like to do an explicit quoting of a string
Quoting from the C-std section 6.7.2.1, struct s { int n; double d[]; };
quoting from The C++ Standard Library by N M Jousttis, Section 5.9 #include <
Quoting from PerlMonks: The difference between my and local , But in real life,
Quoting from here , In C, there are two different namespaces of types: a
Quoting from http://sites.google.com/site/gson/gson-design-document : Why are most classes in Gson marked as final? While
Quoting from Code Complete 2 , int Factorial( int number ) { if (
Quoting from this socket tutorial : Sockets come in two primary flavors. An active

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.