How can I declare a variable which would save sting forever?
I mean if the user closes and restarts the program, this string value is not lost.
How can this be done?
How can I declare a variable which would save sting forever?
I mean if the user closes and restarts the program, this string value is not lost.
How can this be done?
There are a number of different ways to store state for an application. The approach really depends on the type of data you are storing and other requirements
Options
Save the variable value to a database or other storage.
You could save it to a file, a database, a USB drive, somewhere in the cloud... somewhere other than the computer's memory.
Here's a quick example in C# (to write to a file):
string someString = "I will be here forever... well kind of";
using (StreamWriter outfile = new StreamWriter(@"C:\myfile.txt"))
{
outfile.Write(someString);
}