General CS question about constants

后端 未结 7 1360
旧巷少年郎
旧巷少年郎 2021-01-24 02:41

I\'m programming using C#, after programming on C. So I\'m using a lot of constants such as \"DEFAULT_USER_ID\", \"REMOTE_ADDRESS\" and such...

It seems to me that it\'s

相关标签:
7条回答
  • 2021-01-24 03:33

    Another alternative is to store constant values in a .config file, that way you do not need to recompile your application to change your values if needed. Depending on how your code is being deployed, it may or may not be appropriate to have your settings exposed as plain text. See this article for a simple example of using a .config file: http://www.developer.com/net/net/article.php/3396111/Using-Application-Configuration-Files-in-NET.htm

    0 讨论(0)
提交回复
热议问题