我有两个项目(控制台应用程序和设置控制台)。我想要"控制台应用程序"访问"设置控制台" Settings.settings文件并在程序中使用该数据。
我已经将Settings.Settings访问修饰符设置为" Public",并且已将每个设置的范围设置为" User"
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Threading;
using System.Diagnostics;
namespace Settings_Console
{
class Program
{
static void Main(string[] args)
{
//Show Stored Settings
Console.WriteLine(Properties.Settings.Default.Name + "" + Properties.Settings.Default.Number);
String name, number;
name = Console.ReadLine();
number = Console.ReadLine();
Properties.Settings.Default.Name = name;
Properties.Settings.Default.Number = number;
Properties.Settings.Default.Save();
//Show Settings Changed into
Console.WriteLine(Properites.Settings.Default.Name + "" + Properties.Settings.Default.Number);
}
}
}
Amanda 9568675309
Sergio
9568254235
Sergio 9568254235
Press any key to continue . . .
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System_Console;
namespace Console_Application
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine(Settings_Console.Properties.Settings.Default.Name + "" + Settings_Console.Properties.Settings.Default.Number);
}
}
}
Press any key to continue . . .