Domanda

I am writing a program in C# that I plan to have rewritten in different programming languages, for other platforms (namely Mac OSX) in the future. The application needs to save some user-defined settings. My question is, should I save the settings file in such a format that can be read by any programming language, or should I use the app.config built into .NET?

Also what are the benefits of each?

È stato utile?

Soluzione

Well, it depends on how you're planning on implementing it in different platforms. If you use Mono, for example, app.config would be fine. But otherwise, I'd consider using a more neutral file format. XML is the obvious option - particularly if it doesn't need to be hand edited. Or you could use JSON, or a simple key = value one-entry-per-line format.

Of course app.config is XML, but it's an XML format which is specific to .NET. The format used by app.config isn't one you'd normally come up with if you were creating your own settings file in general. I'm sure you'd be able to read an app.config file from other platforms without too much hassle, but it wouldn't be the most natural way of going about it.

Choice of format would partly be dictated by what the settings are - is a single unstructured list good enough, or would you benefit from the tree hierarchy given by XML, for example?

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top