.NET TIPS: Const vs Readonly

xiaoxiao2021-03-06  69

The value of const and readonly can no longer be rewritten once initialization; Const can only initialize the declaration; readOnly can initialize both in the declaration or initialization in the constructor; constiTic STATIC, can no longer write static const; readonly If you don't default, Static, if you need to write static readonly; consT is a constant of compile-static resolution (so its expression must be evaluated when compiling); readonly is a constant of dynamic resolution of runtime; Const can be used to modify Members in the class, can also modify partial variables in the function; Readonly can only be used in the form of a modified class - REFER TO JGMT

转载请注明原文地址:https://www.9cbs.com/read-119526.html

New Post(0)