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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T04:46:49+00:00 2026-05-24T04:46:49+00:00

In another topic , a nice guy told me by quote Eric Lippert’s words:The

  • 0

In another topic, a nice guy told me by quote Eric Lippert’s words:The significance of static has to do with the knowledge and certainties the compiler has at compile time of a certain class/struct/field what have you. It has nothing to do with memory locations and them being fixed or not, etc.

But I’m still not so sure, because the compiler allows something shown below happen.

        struct MyStruct
        {
             public static int[] Arr = {1,3,5};
        }
        static void Test<T>(ref T t) where T:struct
        {
            Console.WriteLine (t);
        }
        void Main()
        {
            Test(ref MyStruct.Arr[2]);//output: as expected 5
        }

Are the ref arguments totally different things compare to the c++ references, or a behind the scene pin happens every time some args are passed by ref? If the static members are movable, how does the runtime guarantee the address of an array element won’t change during the execution of the called function? I’ve learned from an experiment that the return values of objects’ Item prop other than arrays’ are not allowed to be passed byRef. I thought that’s because array elements are allocated in a chunk of continuous memory, but if the whole array is movable, how can one take an address of its elements?

I’m kinda stuck by this uncertainty. I’d very much appreciate it if someone could give some certain answer. Thanks in advance!

~~~~~~~~~~~~~~~~~~

Trying to understand it:

So, any managed operation as long as the compiler allows it happen, We shouldn’t sweat it, right? I have some C/C++ background, I think I understand the meaning of “static” pretty well for c++, only the movability thing of managed code make me dubious. Any managed object, no matter it’s on a stack or managed heap, A ref arg can always point to it correctly, right?

  • 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-24T04:46:50+00:00Added an answer on May 24, 2026 at 4:46 am

    C# ref arguments aren’t totally different from C++ references, but they are different in this respect.

    C# ref arguments are known to the garbage collector and it will adjust them if it promotes objects to a different generation.

    C++ references are invisible to the .NET garbage collector, they will break if the target is not pinned and the garbage collector runs.

    (C++/CLI supports both .NET references and native references)

    If the static members are movable, how does the runtime guarantee the address of a array element won’t change during the execution of the called function?

    It doesn’t. But the function will use the updated address, because it’s .NET code also.

    And none of this changes depending on whether there’s a static field referring to the array. (In fact the array itself isn’t static, only the field referring to it. This fact makes the whole question nonsensical.)

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

Sidebar

Related Questions

I have a task that has a durable subscriber on a JMS topic and
How do you map this url /Topic/topicName/action?topicId=someInt Where Topic is the controller name (this
I have this code to render a file into another file: $(#edit_topics_link).click(function(e){ e.preventDefault(); $(.topic_form).load(/topic_form.html.erb);
Welcome to another findviewbyid() returns null question! I wrote an adapter class for displaying
I know there is alot on this topic already. I got the code below
I've seen this Topic : Creating an instance from a class name and written
sorry for bad Subject of topic but i couldnt find out what to write
I have the following function: $('#topic').change(function() It acts on an ID that's called #topic.
Below is a Matlab function that implements the triangulation method as described in Multiple
So I have a complex form for an IncomeDeclaration. Its going to display a

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.