简体   繁体   中英

Java .properties file and C# .settings file

I'm working on converting a Java code to C#.

The Java code writes and reads 3 key pieces of data in the application into a .properties file. This may even go on for several hundred lines.

Properties prop = new Properties();

I have looked at several C# replacements for .properties files and I've come up with 3 possibilities.

.settings .ini .config

From the non-existent experience I have with these 3 file types, I was thinking that .settings is what I need.

Please correct me if I'm wrong and give me some info on how to work with the best file type. (I've looked into reading and writing to .settings files and there's not much to go on)

Thanks all!

In Visual Studio you would replace that with .settings indeed. If you right click the project and choose to properties then select the Settings tab and you have a nice link to create one if not already there. you can obviously create one using the "add new item"

It can hold standard type such as string , int , double and even more complex one such as Datatable and even custom object

Adding to this, settings also have a scope where you can define at user or application level.

Java .properties file is used to store application settings.

Equivalent for .net application is a .config file. You can then use the whole infrastructure for reading/editing settings.

You can have these setting also in separate file or somewhere else by creating a configuration provider.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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