Ways to store data in .NET

倾然丶 夕夏残阳落幕 提交于 2019-11-30 10:26:26

There are dozens of different ways to store data. It completely depends on what data. Is it:

  • Just a couple of configuration values? Use the built-in Settings library.
  • Machine-wide configuration? Use the registry.
  • Transactional? Use a relational database.
  • Related but not transactional? Use a lightweight database like SQLite or SQLCE.
  • Structured but not related? Use XML or JSON files.
  • Somewhat structured and high in volume? Use a NoSQL solution like MongoDB.

And so on... there are different solutions for every storage requirement and many projects make use of more than one at a time.

If your data is not mission critical (e.g. user preferences), you could just serialise your objects to file, and de-serialise them next time the app is loaded.

TomTom

Examples? Do your homework yourself :)

Anyhow, possible ways are:

  • Registry.
  • Files. Like Microsoft Word does. Or like an ini file, like most games do for example for their settings
  • Databaase

Which makes sense depends on what the application DOES and other scenarios around it. A fast answer is not really possible without knowing more.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!