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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T22:57:47+00:00 2026-05-23T22:57:47+00:00

This is a question regarding best coding practices. I would like to know the

  • 0

This is a question regarding best coding practices.
I would like to know the consensus about how to best avoid hardcoding strings and values in a .NET application.
What I’ve seen so far where I have previously worked:

  • using resource .resx files
  • storing these values and strings in App.config or web.config
  • making a static class ApplicationStrings and declaring all the strings and values in there:

    public static class ApplicationStrings
    {
        #region constants
        public const string APPLICATION_NAME = "X";
        public const string APPLICATION_RESOURCEMANAGER_NAME = "ResourceManagerX";
        public const string APPLICATION_DEFAULT_LOGFILENAME = "log.txt";
    }
    

However, is not the 3rd method, just another hardcode? Does it make sense to have such a class? The benefit would be that all strings are in one place, but is that really avoiding a hardcode?

Also, if you have developed other habits for this situation, feel free to post.

  • 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-23T22:57:48+00:00Added an answer on May 23, 2026 at 10:57 pm

    The main benefit is indeed to have all strings in one place and you only need to change it there to update the whole program. If different parts of your program use the same string and one instance gets updated, but another not, then you have a problem. This holds true for all literals, by the way.

    And then with resource files there is the benefit of i18n and l10n. If you need it, but many large applications should.

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

Sidebar

Related Questions

This is a question regarding Unix shell scripting (any shell), but any other "standard"
First of all there is a partial question regarding this, but it is not
This is a very specific question regarding MySQL as implemented in WordPress . I'm
Question regarding how to setup dbase relationships (newbie, this may be trivial) Followed the
Disclaimer: This is for a homework assignment, but the question is not regarding the
I was reading this question about how to parse URLs out of web pages
Hey, I have a question regarding code structure, and was wondering what the best
This question may be seen as subjective, but I'd like to ask SO users
I've seen this question regading the importing of js-files related to the tag content
After posting this question and reading that one I realized that it is very

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.