如何使用Visual C#设置 [英] How to use settings in Visual C#
本文介绍了如何使用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();
Using Settings in C#
这篇关于如何使用Visual C#设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文