Reputation: 1767
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!
Upvotes: 2
Views: 8731
Reputation: 3302
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.
Upvotes: 2
Reputation: 4440
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.
Upvotes: 6