Changing amount of a const variable at the run time !
-
Hi. I wanna know , Can we change amount of a const variable at run time for ever. I mean , when we change the amount, it will be firm even after closing and running the Application again. Thanks
-
Hi. I wanna know , Can we change amount of a const variable at run time for ever. I mean , when we change the amount, it will be firm even after closing and running the Application again. Thanks
-
Hi. I wanna know , Can we change amount of a const variable at run time for ever. I mean , when we change the amount, it will be firm even after closing and running the Application again. Thanks
Hi, I believe changing a CONST type in the runtime is merely impossible... because its a compile-time constanst... If you want to assign a value at runtime only for once and after if you want to deny any changes then you can use readonly. However all this concepts are valid only when the assembly is loaded in to the memory.. means only while the application is running.... Once the application is stopped then, all the variables and objects in the program is lost whatever the type(CONST or ReadOnly doesnt matter). If you want to retain the changes even after the application is closed, then saving the data in a separate file and accessing it, as and when required is the possible solution.
Have a Happy Coding.....
-
Hi. I wanna know , Can we change amount of a const variable at run time for ever. I mean , when we change the amount, it will be firm even after closing and running the Application again. Thanks
You can distribute the source file with the application, include some code to parse the source, find the text where the const variable is defined and change it. Then your program merely has to rebuild itself, exit and start the new version. :laugh:
Phil
The opinions expressed in this post are not necessarily those of the author, especially if you find them impolite, inaccurate or inflammatory.