0

I want to declare a variable that accept 0,1,-1 but want this variable hold these data (0,1,-1)like database. at first i thought to declare this variable in App.config but App.config is read only. I don't want insert these data in database or in text or XML i want to put these data in source program that any one cant access to them

BenMorel
  • 34,448
  • 50
  • 182
  • 322
mo_al
  • 101
  • 1
  • 9
  • Is the variable only needed at runtime. Can you set it once and than forget it while running? – Andreas Jun 28 '11 at 07:06
  • I set variable when the program is running and i want the variable hold the data and next time when i run program again the variable contain the data – mo_al Jun 28 '11 at 07:43

1 Answers1

2

Configuration Settings are cached in the memory when you starts the application. you can deal with the app.config file as xml to change the values. So you can make changes to it and add you variables to it, they will be reflected the next time you start your application.

Bibhu
  • 4,053
  • 4
  • 33
  • 63
  • this is my code : ConfigurationManager.AppSettings["guide"] = "0"; When the program is running variable(guide) hold "0" but when the program exit the running variable(guide) = -1. I want the variable guide save "0" when the program is not running – mo_al Jun 28 '11 at 07:44
  • @mo_al - Have look at this link. http://stackoverflow.com/questions/5468342/how-to-modify-my-app-exe-config-keys-at-runtime/5468395#5468395 – Bibhu Jun 28 '11 at 07:48