简体   繁体   中英

What's a good way to store large amounts of static data?

I'm currently writing a Windows Store app, and it requires me to include a relative large amount of static data (~1000 different records, each needs a few ints associated). I'm not sure how to approach the problem.

What is a good way to store all this data? It will never be changed in the app as it won't need to be updated.

Have you thought of using Resource Files ?

  1. Make the Best of .NET Resource Files.
  2. Creating and retrieving resources in Windows Store apps.
  3. Working With .resx files Programatically .

Althought they are commonly used for Localization strings, you can pretty much use them for any need such as yours (storing large amounts of static text, or even images).

Also, you can compile the resource file into a binary and include it in your production assembly, for performance and maintenance reasons. See last part of link #3 above.

  • A serializeable file such as XML or JSON.
  • A database.
  • A generic List written in C#
  • An array

I would recommend using a Collection to store all the data.

eg

public const List<string> DATA = new List<String>()
{
    "Data1","Data2","Data3","Data4", "Data5", "Data6"
};

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