Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get and Set values in local resource file

Tags:

c#

I have put 2 strings in the built-in resource file of my main project (not sure how I define this properly). How can I access these values? How would I change them? The resource is public so that the user can change them.

eg:

Project1.Resources.Get("string1").Value();

and

Project1.Resources.Set("string1") = "whatever";

This is pseudo code.

like image 395
user2864613 Avatar asked Oct 10 '13 17:10

user2864613


1 Answers

Resources are not intended to be changed at runtime. You should consider using user settings instead. For details, see Using Application Settings and User Settings on MSDN.

This will allow you to use the designer to build the settings, and write:

string string1 = Properties.Settings.Default.String1;

And:

Properties.Settings.Default.String1 = "whatever";
Properties.Settings.Default.Save();
like image 174
Reed Copsey Avatar answered Sep 28 '22 12:09

Reed Copsey