如何使用Visual C#设置 [英] How to use settings in Visual C#

查看:131
本文介绍了如何使用Visual C#设置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直是一个VB.net开发工作了很长时间,最近更改为C#。
当我用VB.net,调用用户设置,我只需要使用设计器创建一个新的设置,然后从代码My命名空间中调用它。

下面的代码

My.settings.anysetting

我可以改变或从它那里得到的数据。
然而,在C#中的我的关键字是不行的,所以我能做些什么来调用设置??

I have been a VB.net developer for a long time and changed recently to C#. When I was using VB.net, to call user settings, I just need to create a new setting using the designer and then call it from code with the My namespace.
Here's the code
My.settings.anysetting
I can change or get data from it. However in C# the My keyword doesn't work, so what can I do to call settings??

推荐答案

设置保存在应用文件夹中,因此,用它作为自己的命名空间。

Settings are stored under the Application folder and as such, use that as their namespace.

int myInt = Properties.Settings.Default.myVariable;
Properties.Settings.Default.myVariable = 12;
Properties.Settings.Default.Save();

aa730869.aspx>使用设置

Using Settings in C#

这篇关于如何使用Visual C#设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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