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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T22:42:48+00:00 2026-05-26T22:42:48+00:00

private List<string> _S3 = new List<string>(); public string S3[int index] { get { return

  • 0
private List<string> _S3 = new List<string>();
public string S3[int index]
{
    get
    {
        return _S3[index];
    }
}

Only problem is I get 13 errors. I want to call string temp = S3[0]; and get the string value from the list with the particular index.

  • 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-26T22:42:49+00:00Added an answer on May 26, 2026 at 10:42 pm

    You can’t do that in C# – you can’t have named indexers like that in C#. You can either have a named property, with no parameters, or you can have an indexer with parameters but no name.

    Of course you can have a property with a name which returns a value with an indexer. For example, for a read-only view, you could use:

    private readonly List<string> _S3 = new List<string>();
    
    // You'll need to initialize this in your constructor, as
    // _S3View = new ReadOnlyCollection<string>(_S3);
    private readonly ReadOnlyCollection<string> _S3View;
    
    // TODO: Document that this is read-only, and the circumstances under
    // which the underlying collection will change
    public IList<string> S3
    {
        get { return _S3View; }
    }
    

    That way the underlying collection is still read-only from the public point of view, but you can access an element using:

    string name = foo.S3[10];
    

    You could create a new ReadOnlyCollection<string> on each access to S3, but that seems a little pointless.

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

Sidebar

Related Questions

Here's my code: [Serializable()] public class Project { private List<string> _Kinds = new List<string>();
I have a class like this public SomeClass { private List<string> _strings = new
private List<T> newList; public List<T> NewList { get{return newList;} set{newList = value;} } I
I have a List private List<string> additionalHeaderMeta = new List<string>(); and I want to
private List<String> subList; private List<List<String>> records = new ArrayList<List<String>>(); for(....){ subList = new ArrayList<String>();
Assume the following class: public class MyEnum: IEnumerator { private List<SomeObject> _myList = new
Given a generic class: class MyClass ( private List l = new LinkedList <String>();
private List<String> longStr = new java.util.ArrayList<String>(); private List aList = null; private String []
I have 3 classes public class Test { private List<Question> _questions; private string _text;
@XmlRootElement(name = toplist) class toplist { private String description; private List<Item> items= new ArrayList<Item>();

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.