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

  • Home
  • SEARCH
  • 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 351509
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T11:39:01+00:00 2026-05-12T11:39:01+00:00

It seems strange that the language apparently includes no suitable functionality. I find myself

  • 0

It seems strange that the language apparently includes no suitable functionality.

I find myself with data that would best be expressed as a multi-dimensional array but it’s utterly constant, there is no way anyone could want to change it without also changing the associated code. Faced with such stuff in Delphi the answer is obvious–a constant whose value is the table. However, C# doesn’t seem to support anything like this.

Google shows many people griping about this, no good answers.

How do people handle this sort of situation?

(And don’t say that constants don’t belong in code–the last one I bumped into was all possible permutations of 4 items. Unless the very nature of spacetime changes this is set in stone.)

What happened?? There was an answer that came pretty close, I was asking about a detail and it vanished! Simply declaring an array sort of does the job–the only problem is that the array allocation is going to run every time. The one in front of me contains 96 values–how do I get it to initialize only once? Do I just have to accept scoping it far wider than it should be? (As it stands it’s in one 3-line routine that’s inside what amounts to an O(n^3) routine.)

  • 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-12T11:39:01+00:00Added an answer on May 12, 2026 at 11:39 am

    There’s a page in in the C# FAQ about this specific thing.

    They suggest using a static readonly array:

    static readonly int[,] constIntArray = new int[,] { { 1, 2, 3 }, { 4, 5, 6 }};
    

    However, be aware that this is only sort of constant – you can still reassign individual elements within the array. Also, this has to be specified on the class level since it’s a static, but it will work fairly well.

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

Sidebar

Related Questions

It seems strange that the flagship language of .NET would include programming constructs that
I have an example that seems strange to me. public class Join { public
Most of Knockout seems very intuitive. One thing that is strange to me though
There doesn't seem to be a question for this, and it seems strange that
I know that even a question Erlang or Java seems quite strange, because they
It seems strange that I have to manually execute SQL to use the TRUNCATE
So, the question might seem strange, but let's say that I compile: int main(void)
I am having a strange issue that I can't seem to resolve. Here is
I have a strange problem that I can't seem to solve. I've quite a
I came across a strange behaviour with Chrome earlier that I can't seem to

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.