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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T09:55:24+00:00 2026-06-01T09:55:24+00:00

I know the general difference between value type and reference type, and I also

  • 0

I know the general difference between value type and reference type, and I also know when using a value type in a reference type, this value type is actually on the heap.

ex:

class ClassA{
   public DateTime date1 = new DateTime(2008, 3, 1, 7, 0, 0);
}

when

ClassA a = new ClassA();

the date1 is on heap

My question is

if we use this date1 as a parameter in a method, what’s the memory location behavior?

public void methodA(DateTime dt)
{
//do sth with the dt
}

invoke the method

methodA(new ClassA().date1);

Option 1: Just copies one date1 reference
Option 2: Or copy date1 data to run

UPDATE:
After reading the “the truth about value types”, i realised there are some uncertainties in my assumption. At least I should give a context like. “in the Microsoft implementation of C# on the desktop CLR, value types are stored on the stack when the value is a local variable or temporary that is not a closed-over local variable of a lambda or anonymous method, and the method body is not an iterator block, and the jitter chooses to not enregister the value.”

Update2:
The reason I asked about this is I want to understand some code snippet on http://marcgravell.blogspot.co.uk/2011/10/assault-by-gc.html

change Customer from a class to a struct (only within this crazy code)

change the main store from a List to a Customer[]

change the subsets from List to List, specifically the
offset intothe main Customer[]

void SomethingComplex(ref Customer customer) {...}
...
int custIndex = ...
SomethingComplex(ref customers[custIndex]);
  • 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-01T09:55:26+00:00Added an answer on June 1, 2026 at 9:55 am

    DateTime is a value type, so the value will be copied on method invocation.

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

Sidebar

Related Questions

In general I want to know what is the difference between bug and exception?
I know the general guidelines to double-postbacks, but this one is driving me nuts
i just want to know a general information about this particular information. Any good
I know this SO question, but it deals with the subject in more general
what is the difference between these statements? I know that var $test declares a
In terms of general operating system concepts, what is the difference between a file
This is more of a general question about the distinctions between these four different
EDIT: 1. Let's not make this a general vim/emacs debate. I know some people
This is a cgal related question, but I think it is also a general
I know in general it is a good practice to move as much processing

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.