we are trying to create a app that shows the user messages. Here are some example messages:
We are getting these strings from our database. (Our first attempt was to make a class, with different functions, that gave us back the strings. We used string interpolation. Then we realized that this is no good option, because the users can't create contents/strings by themselves and we have to update our app every time we create a few more strings in this class.)
The options we know:
String.format: something like that:
string result = string.Format("{1} blalbal...- {2}blabla... {3}", value1, value2, value3);
The problem here: We want to use strings with different positions of the input like in our examples. Sometimes the first one is the playername, sometimes it is the clubname...
Questions:
You can simply store the string format in the database, the order of the variables doesn't need to be consistent?
SQL Database
"You have an offer for {0} from {1}. They would pay {2}."
"{1} would like to buy {0} for {2}."
You could even leave out arguments if you wanted.
"{1} would like to buy {0}, they would like to discuss pricing."
c#
string format = GetStringFromDatabase(someIdentifier);
string message = String.Format(format, PlayerName, Offerclub, Offer);