2
Hello
You should do like this :
- class Program
- {
- readonly bool flag ;
- Program()
- {
- flag = true;
- }
-
- static void Main(string[] args)
- {
- Program p = new Program();
- Console.WriteLine(p.flag);
- Console.ReadKey();
- }
- }
Explaination :
There is two possibility to define value to readonly property :
1 . You can directly define when declaration like :
- readonly bool flag =false ;
2 . Define value
with constructor :
- Program()
- {
- flag = true;
- }
I hope it helps
Thanks
Accepted 1
Hello
Always welcomed any doubts in future !!!
Thanks
1
Thank you Manav Pandya ! You have cleared my doubt.