user2864613
user2864613

Reputation: 189

Get and Set values in local resource file

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.

Upvotes: 6

Views: 21365

Answers (2)

Dev
Dev

Reputation: 165

You can get resource by writing the following piece of code

    Project1.Resources.String1

You can not change it at runtime.

Upvotes: 0

Reed Copsey
Reed Copsey

Reputation: 564323

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();

Upvotes: 18

Related Questions