Const vs. readonly vs. static readonly in C# .NET(visualcppsupport.blogspot.com)
submitted by
gsanthoshbe(69) 2 years, 1 month ago
Here are the differences between C# .NET const, readonly and static readonly fields.
Constants:
Static by default
Must have compilation-time value (i.e.: you can have "A"+"B" but cannot have method calls)
Can be used in attributes
Are copied into every assembly that uses them (every assembly gets a local copy of values)
Could be declared within functions
The compiler performs some optimization by not declaring any stack space for the field
|category: C#
|Views: 23
tags:
C# another
Everyones tags:
Your Tags: