如何在程序退出时保存变量值? [英] How to save variable values on program exit?

查看:29
本文介绍了如何在程序退出时保存变量值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 ArrayList 来存储可变数量的字符串,并且想知道如何保存 ArrayList 及其元素,以便我的 windows 窗体可以在程序加载和退出之间调用它们的值.

I am trying to use an ArrayList to store a variable number of strings, and would like to know how to save the ArrayList and its elements so that my windows form can recall their value between program load and exit.

我曾经将信息存储在文本文件中,但希望尽可能避免使用外部文件.

I used to store the information in a text file, but would like to avoid external files if possible.

感谢您提供的任何帮助.

Thank you for any help you could provide.

推荐答案

您可以使用 Properties.Settings 最好的部分是它允许您在应用程序和用户级别设置变量

You can save the ArrayList (if not ArrayList their are other equivalent classes) using Properties.Settings best part is it allows you the setting variable at Application and user level

一个很好的例子可以在这里找到如何使用 Settigns http://www.codeproject.com/Articles/17659/How-To-Use-the-Settings-Class-in-C

A very good example can be found here how to use Settigns http://www.codeproject.com/Articles/17659/How-To-Use-the-Settings-Class-in-C

这篇关于如何在程序退出时保存变量值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆