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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T17:56:32+00:00 2026-05-23T17:56:32+00:00

How are the Indexers are defined in List and Arrays. List<MyStruct> lists=new List<MyStruct>(); where

  • 0

How are the Indexers are defined in List and Arrays.

List<MyStruct> lists=new List<MyStruct>(); where MyStruct is a Structure. Now Consider
MyStruct[] arr=new MyStruct[10];

arr[0] gives a reference to the first Structure item.But lists[0] gives me a copy of it.
Is there any reason why it is done like that.
Also since Int32 is structure List<Int32> list1 =new List<Int32>(); how it is possible for me to access list1[0] or assign list1[0]=5 where as it is not possible to do lists[0]._x=5

  • 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-23T17:56:32+00:00Added an answer on May 23, 2026 at 5:56 pm

    Although they look the same, the array indexer and list indexer are doing completely separate things.

    The List<T> indexer is declared as a property with a parameter:

    public T this[int index] { get; set; }
    

    This gets compiled to get_Item and set_Item methods that are called like any other method when the parameter is accessed.

    The array indexer has direct support within the CLR; there is a specific IL instruction ldelema (load element address) for getting a managed pointer to the n’th element of an array. This pointer can then be used by any of the other IL instructions that take a pointer to directly alter the thing at that address.

    For example, the stfld (store field value) instruction can take a managed pointer specifying the ‘this’ instance to store the field in, or you can use the pointer to call methods directly on the thing in the array.

    In C# parlance, the array indexer returns a variable, but the list indexer returns a value.

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

Sidebar

Related Questions

I was trying to bind my DataGrid columns to a list where the item
How can I list indexes columns readily defined in Oracle? And how do I
I am looking for a framework-defined interface that declares indexer. In other words, I
I am using a DBD::SQLite in memory database. I have defined the following indexes
I was reading about Indexes in databases. First, I have my original table. Then
Can we get a list of basic optimization techniques going (anything from modeling to
I have a restaurants table with a name column. I've defined the following index:
We have a mid-size SQL Server based application that has no indexes defined. Not
I have defined tab index for the input fields in a form. When tabbing
To save the memory, I defined some record-like structs and stored their instances in

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.