What is the difference between const and readonly in C#?

前端 未结 30 3301
挽巷
挽巷 2020-11-22 05:05

What is the difference between const and readonly in C#?

When would you use one over the other?

30条回答
  •  离开以前
    2020-11-22 05:23

    Read Only : Value can be changed through Ctor at runtime. But not through member Function

    Constant : By default static. Value cannot be changed from anywhere ( Ctor, Function, runtime etc no-where)

提交回复
热议问题