Difference between ReadOnly and Constants
-> A constant is initialized at the time of its creation i.e Compile Time.
-> A ReadOnly can be assigned once in the class constructor allowing you to pass the value at Runtime.
Advantages of declaring Constant
->Declaring fields as constants protects from changing the value accidentally.
->Using constants we perform some optimization by not declaring any stack space for that field.
search
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment