-3

So, here is my current issue: I simply want to save about 500 different strings.

My question then is what is the best way to do this?

All the strings are suppose to be loaded afterwards. The idea is that one label will be able to present all of these strings depending on the users previous input.

Do I really need to call a function 500 times or write 500 if-statements? Furthermore do I need to save this data 500 different times and if so what method is the best one to use?

rmaddy
  • 314,917
  • 42
  • 532
  • 579

1 Answers1

0

If you want to load all 500 strings independent of the input, you can simply store an array of strings. On the other hand, if you want to select a specific string from those 500 strings based on the input, you can store a dictionary with 500 key:value pairs. The keys can be expected input and value will be its respective string. This will get you the desired string at runtime.

Moeez Z.
  • 16
  • 2
  • Okay, but if I store them all in an array I would still need to call them separately right? With would lead to 500 different calls and if statements or am I wrong? – albin öberg Dec 16 '17 at 17:50
  • why do you need if statements? do you need to get one of the 500 strings depending on the input text at runtime? if yes, why dont you use a dictionary? If the choosing of strings is not dependent on the input, you can simple print all strings using a a simple for loop on the array. – Moeez Z. Dec 17 '17 at 19:21