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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T02:50:06+00:00 2026-05-14T02:50:06+00:00

System.Array serves as the base class for all arrays in the Common Language Runtime

  • 0

System.Array serves as the base class for all arrays in the Common Language Runtime (CLR). According to this article:

For each concrete array type, [the] runtime adds three special methods: Get/Set/Address.

and indeed if I disassemble this C# code,

int[,] x = new int[1024,1024];
x[0,0] = 1;
x[1,1] = 2;
x[2,2] = 3;
Console.WriteLine(x[0,0]);
Console.WriteLine(x[1,1]);
Console.WriteLine(x[2,2]);

into CIL I get,

IL_0000:  ldc.i4     0x400
IL_0005:  ldc.i4     0x400
IL_000a:  newobj     instance void int32[0...,0...]::.ctor(int32,
                                                         int32)
IL_000f:  stloc.0
IL_0010:  ldloc.0
IL_0011:  ldc.i4.0
IL_0012:  ldc.i4.0
IL_0013:  ldc.i4.1
IL_0014:  call       instance void int32[0...,0...]::Set(int32,
                                                       int32,
                                                       int32)
IL_0019:  ldloc.0
IL_001a:  ldc.i4.1
IL_001b:  ldc.i4.1
IL_001c:  ldc.i4.2
IL_001d:  call       instance void int32[0...,0...]::Set(int32,
                                                       int32,
                                                       int32)
IL_0022:  ldloc.0
IL_0023:  ldc.i4.2
IL_0024:  ldc.i4.2
IL_0025:  ldc.i4.3
IL_0026:  call       instance void int32[0...,0...]::Set(int32,
                                                       int32,
                                                       int32)
IL_002b:  ldloc.0
IL_002c:  ldc.i4.0
IL_002d:  ldc.i4.0
IL_002e:  call       instance int32 int32[0...,0...]::Get(int32,
                                                        int32)
IL_0033:  call       void [mscorlib]System.Console::WriteLine(int32)
IL_0038:  ldloc.0
IL_0039:  ldc.i4.1
IL_003a:  ldc.i4.1
IL_003b:  call       instance int32 int32[0...,0...]::Get(int32,
                                                        int32)
IL_0040:  call       void [mscorlib]System.Console::WriteLine(int32)
IL_0045:  ldloc.0
IL_0046:  ldc.i4.2
IL_0047:  ldc.i4.2
IL_0048:  call       instance int32 int32[0...,0...]::Get(int32,
                                                        int32)
IL_004d:  call       void [mscorlib]System.Console::WriteLine(int32)

where the calls to the aforementioned Get and Set methods can be clearly seen. It seems the arity of these methods is related to the dimensionality of the array, which is presumably why they are created by the runtime and are not pre-declared. I couldn’t locate any information about these methods on MSDN and their simple names makes them resistant to Googling. I’m writing a compiler for a language which supports multidimensional arrays, so I’d like to find some official documentation about these methods, under what conditions I can expect them to exist and what I can expect their signatures to be.

In particular, I’d like to know whether its possible to get a MethodInfo object for Get or Set for use with Reflection.Emit without having to create an instance of the array with correct type and dimensionality on which to reflect, as is done in the linked example.

  • 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-14T02:50:07+00:00Added an answer on May 14, 2026 at 2:50 am

    Look here, specifically section 14.2 on pages 63-65

    http://download.microsoft.com/download/7/3/3/733AD403-90B2-4064-A81E-01035A7FE13C/MS%20Partition%20II.pdf

    But the takeaway, and you can tell from the IL, is that they’re the getter and setter methods for dealing with arrays at the given index positions.

    • A Get method that takes a sequence of
    int32 arguments, one for each
    dimension of the array, and returns a
    value whose type is the element type
    of the array. This method is used to
    access a specific element of the array
    where the arguments specify the index
    into each dimension, beginning with
    the first, of the element to be
    returned.

    • A Set method that takes a sequence
    of int32 arguments, one for each
    dimension of the array, followed by a
    value whose type is the element type
    of the array. The return type of Set
    is void. This method is used to set a
    specific element of the array where
    the arguments specify the index into
    each dimension, beginning with the
    first, of the element to be set and
    the final argument specifies the value
    to be stored into the target element.

    • An Address method that takes a
    sequence of int32 arguments, one for
    each dimension of the array, and has a
    return type that is a managed pointer
    to the array’s element type. This
    method is used to return a managed
    pointer to a specific element of the
    array where the arguments specify the
    index into each dimension, beginning
    with the first, of the element whose
    address is to be returned.

    Edit: That’s pages 63-65 using the document’s page numbering. 73-75 in the actual PDF.

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

Sidebar

Related Questions

How do I mock the method GetValues() in System.Data.IDataReader? This method changes the array
Is there anything more compact (or otherwise better) than this? <x:Array x:Key=titles Type=System:String> <System:String>Mr.</System:String>
String a []= {null,null,null,null,null}; //add array to arraylist ArrayList<Object> choice = new ArrayList<Object>(Arrays.asList(a)); System.out.println(choice.size());
System.out.println( Arrays.deepToString( abc<def>ghi.split((?:<)|(?:>)) ) ); This prints [abc, def, ghi] , as if I
I have the following code: <h2>Add System</h2> <?php echo $this->Form->create('ReleaseServer'); echo $this->Form->input('server_name',array('error'=>array( 0 =>
What’s the difference between the System.Array.CopyTo() and System.Array.Clone() ?
Is it possible to somehow mark a System.Array as immutable. When put behind a
I have an array of strings. How can I convert it to System.Collections.ArrayList?
I have two arrays of System.Data.DataRow objects which I want to compare. The rows
The toArray method in ArrayList , Bloch uses both System.arraycopy and Arrays.copyOf to copy

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.