Click here to Skip to main content
15,881,864 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Is it a good way to store commonly used constants to a static class? If not then what can be the efficient way to do the same? Need Suggestions.

Thanks and Regards,

GPUToaster
Posted

1 solution

Depending on how 'constant' it is I usually put things into the standard Properties.Settings class for the assembly. This means you can amend the 'constant' on an environment by environment basis.

If it's always going to be same regardless, then a static class containing the constant is as good a way as any - you could expose them as readonly properties but a public constant field will work.

For large blocks of text that are constant...say long paramterised TSQL statments... I've 'repurposed' the assembly resources to as it's much easier to copy and paste multiline text than having to convert to/from a multiline string.

Hope this helps.
 
Share this answer
 
Comments
GPUToaster™ 20-May-10 6:59am    
I have around 20-30 Constants which need to be included and they are not going to change. So i guess Static class would do for me. Thanks for clearing my doubts. :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900