简体   繁体   English

属性文件像Java中一样简单?

[英]Properties file as simple as in Java?

I am looking for a simple way to use values written in my properties.resx file in C#. 我正在寻找一种简单的方法来使用在C#中的properties.resx文件中编写的值。 In Java, this is really simple since you have a file .properties . 在Java中,这非常简单,因为您有一个.properties文件。
I need such file to write my constant strings inside as if I want to change a constant, I just have to change it in that file. 我需要这样的文件将我的常量字符串写入其中,就好像我想更改一个常量一样,我只需要在该文件中进行更改即可。 Anyone has an example? 有人举个例子吗?

Thanks in advance. 提前致谢。

In .NET we typically don't use a resx file to store settings like you describe, we use a settings class. 在.NET中,我们通常不使用resx文件来存储您所描述的设置,而是使用设置类。 Go to the properties for your project and click on the Settings tab. 转到项目的属性,然后单击“设置”选项卡。 Create your settings there and they'll be written to the app.config/web.config where they can be overridden. 在此处创建您的设置,这些设置将被写入app.config / web.config中,在其中可以覆盖它们。 You can then access the values using Settings.Default.NameOfSetting . 然后,您可以使用Settings.Default.NameOfSetting访问值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM