Saving Data or Variable for future use? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Saving Data or Variable for future use?

how can i save a variable for future use? if the program is terminated and again opened the Variable will same as seted while exiting? any help pz...

9th Oct 2016, 12:28 AM
AB Sattar Solangi
AB Sattar Solangi - avatar
9 Answers
+ 2
Saving to the registry isn't recommended (what if the program is run on a different computer or the user doesn't have write access.) Visual Studio has the ability to create application settings: https://msdn.microsoft.com/en-us/library/25zf0ze8(v=vs.100).aspx Otherwise, the simplest way would be to save a text file with the value.
9th Oct 2016, 11:59 PM
Liam
Liam - avatar
+ 1
Save its value in a database or in a text file before you exit your program and retrieve in when your program reloads.
9th Oct 2016, 3:31 AM
Erwin Mesias
Erwin Mesias - avatar
+ 1
Or into Windows registry.
9th Oct 2016, 4:50 AM
Ivan G
Ivan G - avatar
0
no there is another methode i saw in Vb maybe its code is different?
9th Oct 2016, 11:42 AM
AB Sattar Solangi
AB Sattar Solangi - avatar
0
This may be useful https://msdn.microsoft.com/en-us/library/bb397750(v=vs.110).aspx
9th Oct 2016, 8:45 PM
Ivan G
Ivan G - avatar
0
Use file descriptors or database.
9th Oct 2016, 11:39 PM
Evgeny Volnov
Evgeny  Volnov - avatar
0
@Evgeny Volnov how? will u explain please?
9th Oct 2016, 11:41 PM
AB Sattar Solangi
AB Sattar Solangi - avatar
0
Some techniques based on OS you use. I think the most common OS for C# will be windows, so check out official Microsoft documentation. https://msdn.microsoft.com/en-us/library/kdfaxaay.aspx For example just create a file and write variable value each line. After launching just parse each line to variable. It's easiest way to store your data. About database: make local db using simple SQLite (find some info in Google). Every time your app is launching all the variables will initialising via queries to your database. It's complicated way, but you could try.
9th Oct 2016, 11:50 PM
Evgeny Volnov
Evgeny  Volnov - avatar
0
thanks for this man.
9th Oct 2016, 11:54 PM
AB Sattar Solangi
AB Sattar Solangi - avatar