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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T05:00:32+00:00 2026-05-20T05:00:32+00:00

This is my first question after having used this place as my go to

  • 0

This is my first question after having used this place as my “go to” for a general opinion on what works/doesn’t/why and the such. So let’s try this out…

With my limited experience I’ve been trying to get my head round the better ways of creating fixed data fields that I can refer back to throughout my program – things like end-user-viewable strings that I show repeatedly and other parameters that I’d like to keep constant and safe from change. I’ve kept my reused data in separate static classes and put my strings in private static readonly arrays that I expose through the use of wrapping in private ILists that have public getters that return the single string I’m after. Hopefully I’ve not abused terminology so far!
What I’ve done so far:

namespace MyNamespace
{
    public static partial class Tables
    {
          private static readonly string[] _Messages =
                  {
                      "One",
                      "Two"
                  };

          private static readonly IList<string> MessagesReadOnly = Array.AsReadOnly(_Messages);
          public static IList<string> Messages { get { return MessagesReadOnly; } }
    }
}

That much I understand but now I’ve got a 2 dimensional table of data (int) that I need to store in a similarly non-exposed manner that I can access.
This data is going into its own class as now I’m dealing with a separate real-world data type.
Real-world scenario – I’ve got different fuels with their associated combustion constants that I’ll need to access to perform combustion analysis using data that I get from a gas analyser. So I want to keep these arrays/lists separate with all their methods but I can’t seem to figure out how to do this.

If I do like I did before and go via the route of array (but 2D this time) then I run into the issue that it seems (according to info on MSDN) that Array.AsReadOnly(myArray) only works for one-dimensional arrays. I’m not savvy enough to know exactly how to write my own to work around this (assuming that’s a simple enough task). So then if I go to trying to use jagged arrays, as that seems to be the other viable route I’ve found, I get stuck trying to figure out how and where to create the initial jagged array (constructor or as class method) and then what about where to initialise the array within that?

If I didn’t need to protect the array then I can put it all in the constructor and that might be ok (as far as I can tell so far) but I have to keep it non-exposed. The first way I understood how that programatically fit within a class but trying to use jagged arrays non-exposed has got me all muddled up. All the examples I see on the web seem to create them and initialise within main which is fine (although exposed) but as I’m putting this elsewhere how can I make it available to anything that might need the data whilst not exposing them?

Hopefully you understand why I feel like I’m going in circles, maybe the answer is really simple and I’m missing the obvious but until I see someone else do similar I can’t figure it out, and I haven’t been able to find anything close enough to give me the clues. If there already exists a similar post on SO please point me in that direction. Like I’ve said, I’ve scoured both MSDN, SO and wandered the web in search of breadcrumbs.

Let me know if you need more info about what I’ve been trying and thanks for reading.

I’ve just been adding tags to this question and seen that there’s an Array tag so I’m off to see if I can narrow things down some more there. Not sure if I should add that tag too, I could add Lists also…?

  • 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-20T05:00:33+00:00Added an answer on May 20, 2026 at 5:00 am

    This data is going into its own class as now I’m dealing with a separate real-world data t

    If you’re going to be storing this in a custom class, you could just write a custom read-only indexer property for that class.

    This would look something like:

    private YourType[,] internalArray; // Create and set this up in constructor or elsewhere...
    
    
    public YourType this[int row, int column]
    {
         get 
         {
              return internalArray[row,column];
         }
    {
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hello stackoverflow guru's! This is my first post after having used the site for
though I have visited this site many times, this is my first question. After
I'm posting my first question here after having viewed many useful exchanges by others;
I was wondering, after having read this question ... he has this code: public
Two things, first this is my first question in this forum and I do
This is my first question, so maybe it is a silly one. I have
this is my first question at stackoverflow, so bear with me. In my local
This is my first question on the site and I hope it's not too
This is my first question ever here on stackoverflow! I've been searching for a
This is my first question here, hope to be useful in future to someone.

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.