Home / General / 'const' vs 'static readonly'
digWin is a community news sharing site for Microsoft Techies. Share interesting news/links and rate them!

'const' vs 'static readonly'

I'm a big fan of reusing code whenever and wherever possible.  A long time ago, I wrote an assembly that provided common methods and data to some applications I was writing.  When I first wrote the assembly, I exposedthe common data as public fields decorated with the const keyword, as shown in the example below.public class HelperData{    public const Int32 Iterations = 5;}When I used the field, in my application, I saw the expected results, and checked in my code.The value of HelperData.Iterations is





Microsoft news, tips and tricks search

Comments


Post voted by 1 digWinners


Featured Links

User

Login | Register




Forgot Password?

Sponsor

Anti spam filter for mail servers
Anti spam, anti phishing and email management software for Exchange/SMTP/Lotus. Download a FREE trial!

Featured

Download Free Exchange Ebook

Categories

Upcoming NEW

Recent comments

Related Sites