Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Store data in C# source files vs. XML etc...?

This is a C# question.

I was just wandering if anyone tried storing their data (like config files for example), in the *.cs file, instead of XML?

I really hate XML. The whole idea of parsing html-like structure every time you need some data seems stupid.

Are there lightweight alternatives (like YAML) to XML? In my case I actually need to store some data for a (game) Level, where there are a lot of different objects, terrain types, etc... in a flat file, so I can read it later.

I guess I could serialize my Level class, but I want the data-file to be EDITABLE in any text editor for example.

Any help would be welcome, thanks!

PS: Regarding .cs files, I forgot to mention that I want the ability to create (and save) new levels in game, through an editor.

like image 831
Andriy Drozdyuk Avatar asked Dec 28 '25 11:12

Andriy Drozdyuk


1 Answers

I've been working in the game industry for years, and we use XML because it's got the best tool support. Yaml or Ini files are used for configs, but game data is stored in XML. Of course we normally have tools that convert XML into binary code, for shipping games, but during development and custom game tools development XML simply rocks.

Sometimes XML is the right hammer for your needs, don't place prejudice on technologies just because they aren't the best in some fields (say Ajax(transport) vs Data Definition)

like image 136
Robert Gould Avatar answered Dec 31 '25 00:12

Robert Gould



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!