Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C# Console Application - Edit User Setting at runtime

I had a Winforms App with a propertyGrid to let the user edit his settings.
How to achieve the same goal whithin a Console Application?

ANSWER
Thanks to those who answered. Here is a synthetic code based on a few answers :

Console.WriteLine("Choose user settings to setup");
Console.WriteLine("User setting1: press 1");
Console.WriteLine("User setting2: press 2");

string line = Console.ReadLine();
int code = int.Parse(line);
swicth(code) 
{
   case 1: 
    Settings.Default.MyProperty = line ;
    Settings.Default.Save();
    break;

   case 2: 
    ...
 }
like image 724
Mehdi LAMRANI Avatar asked Nov 17 '25 06:11

Mehdi LAMRANI


1 Answers

Settings.Default.MyProperty1 = "some value";
Settings.Default.MyProperty2 = 2;
Settings.Default.Save();
like image 88
wildcat Avatar answered Nov 19 '25 20:11

wildcat



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!