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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T06:06:35+00:00 2026-06-11T06:06:35+00:00

I need to check for a certain version in one of my components. For

  • 0

I need to check for a certain version in one of my components. For that reason I just wanted to introduce a public const int on which I could test.

However, I just read in this SO post When, if ever, should we use const? that it’s probably a bad idea to use a const whenever something changes in the future.

What’s the best way to do that? Using a public readonly int? Using an attribute? I can’t use AssemblyVersion or AssemblyFileVersion as those are not in my hand…

Thanks!

  • 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-06-11T06:06:36+00:00Added an answer on June 11, 2026 at 6:06 am

    I’d use the const (in fact, I do use it for that). readonly is initialised at run-time, in fact, it can have a different value every time you run the application [1]. Because of that propery, I’d say it is less useful for a version number.

    A version number is (should be?) hard-coded at compile time, which would be a const. Comparison could be a #define in C.

    I reckon that because of this difference, a const doesn’t use data memory, as a readonly does. I have no sources for that though.

    [1] http://en.csharp-online.net/const,_static_and_readonly

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

Sidebar

Related Questions

I've written an script that updates a version on a certain file. I need
I've got a few Unix shell scripts where I need to check that certain
I need to check if a link (a-tag) is the only content (not just
I need to check if my address has any words that matches word in
I need to check a certain selection of checkboxes using JavaScript. All these checkboxes
So if this qstring var is set then i need to check a certain
I need to check if certain keyspace exists in Cassandra database. I need to
I need to check in my code changes to a certain branch but im
I need to check whether a certain class extends or implements a particular interface.
I need to check if a certain variable is a generator object. How would

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.