development:language:net:csharp:setting.cs
設定情報を保存
古くはApp.configをいじっていましたが、最近ではVSが良きに計らってくれる。
値の設定
プロジェクト → プロパティ → 設定画面 で値を設定します。
うらで、勝手にsettingファイルが作成されます。
Sampleコード
using System; namespace MyProject.SettingTest { class Program { static void Main(string[] args) { Console.WriteLine("Name : {0}", Properties.Settings.Default.Name); Console.WriteLine("Age : {0}", Properties.Settings.Default.Age); Console.WriteLine("\nPlease Input New Name..."); string x = Console.ReadLine().ToString(); Properties.Settings.Default.Name = x; Properties.Settings.Default.Save(); Console.WriteLine("saveed configuration"); Console.WriteLine("Setting Name : {0}", Properties.Settings.Default.Name); Console.ReadKey(); } } }
development/language/net/csharp/setting.cs.txt · 最終更新: 2017/04/14 05:21 by 127.0.0.1