Consts in .NET !!!

Recently, I had to use some consts in my C# code. I had a class that simply had const string variables; DB table names etc. My program was not working well and I started debugging and in the debugger, I learnt that the const variables did not show the string values I had assigned. I did rebuilt and other non-sensical stuff like that until I learnt this about the consts in .NET:- const variables in .NET do not exist as variables out of the assembly they exist in. Instead, during compilation, they get embedded (hard-coded) where ever you use them, and so when you debug, you do not see the proper value that you had assigned. For debugging purposes you have to output diagnostic trace messages and verify.

Show Comments