+ 3
What is the difference between the 'const' and 'readonly' keywords?
2 Antworten
+ 1
You can reaad about it here: https://www.c-sharpcorner.com/UploadFile/2072a9/constant-vs-readonly-vs-static-keywords-in-C-Sharp/
But to quickly and roughly summarise; a const variable needs to be assigned at compile time when it is declared, whilst a readonly variable can have a value assigned to it when it is declared or in the constructor of the same class.
There are other differences as well and can be found in the linked article