Readonly and const both are same they can never be modified. But
readonly allows initializing variables at run time.
const must be initialized to a compile time constant.
Ex:
public readonly DateTime dt = DateTime.Now
public const int i = 2;
http://en.csharp-online.net/const,_static_and_readonly
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment