How do I save/serialize a custom class to the settings file?

前端 未结 4 571
礼貌的吻别
礼貌的吻别 2020-12-03 03:28

I have a small class that holds two strings as follows:

    public class ReportType
    {
        private string displayName;
        public string DisplayNa         


        
4条回答
  •  半阙折子戏
    2020-12-03 03:58

    Just a bit more clear code then Charlie's

    public class ReportType
    {
      public static ReportType CreateDefaults()
      {
        return new ReportType
        {
           DisplayName =  ConfigurationManager.AppSettings["DefaultDisplayName"],
           ReportName = ConfigurationManager.AppSettings["DefaultReportName"]
        };
      }
    }
    

提交回复
热议问题