是否有java.util.Properties类的C#模拟 [英] Is there a C# analogue of java.util.Properties class

查看:381
本文介绍了是否有java.util.Properties类的C#模拟的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Java有一个属性类,它是很好的保存基本配置信息,例如,你想有一个GUI设置坚持从一个会话到下一个。它节省和我记得,是使用相当简单检索键值对。我一直在寻找这在C#中,但没有成功的模拟。我错过了吗?

Java has a Properties class that is nice for saving basic configuration information, e.g. a gui setting you would like to have persist from one session to the next. It saves and retrieves key value pairs as I recall and is quite simple to use. I have been looking for an analogue of this in C# but without success. Am I missing it?

如果没有一个,有什么超越简单的存储/读取保存简单的应用程序设置一个custrom文本文件? (测度的超越是简单)。

If there isn't one, is there anything above and beyond simply saving / reading a custrom text file for saving simple application setting? (Measure of "above and beyond" being simplicity).

推荐答案

如果您创建一个标准的.NET项目并转到属性,然后去设置,然后单击创建一个,你应该能够完成你想要那里。这将允许你使用Properties.Settings这有利于坚持的用户设置。

If you create a standard .NET project and go to Properties, then go to Settings, then click to create one, you should be able to accomplish what you want there. That will allow you use Properties.Settings which is good for persisting user settings.

如果你想要的应用程序范围的设置,在app.config(编译为MyApplication.exe.config )是要走的路。您可以通过访问这些ConfigurationManager.AppSettings设置(需要System.Configuration集引用)

If you want application wide settings, the app.config (compiled as MyApplication.exe.config) is the way to go. You can access these settings via ConfigurationManager.AppSettings (requires System.Configuration assembly reference)

这篇关于是否有java.util.Properties类的C#模拟的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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