I have this code:
public async Task ShowTimedCard()
{
phrase = phrases[(int)AS.rand.Next(phrases.Count)];
It gets a random number and then selects a phrase from phrases
which is a List of phrase
rows. The List has items added and removed from it by a background process.
Each phrase has an Id
field. I cannot remove phrases that I have used from the List for other reasons.
Sometimes ShowTimedCard picks the same phrase twice in a row so I decided to store the lastPhrase information in a static variable like this:
AS.phrase.id = phrase.id
How can I make it so if there are more than 1 items in the phrases
List then it will not pick the same phrase twice in a row? I was thinking of some kind of while loop or until loop but not sure how to implement that. I guess it needs to compare the phrase.Id with the AS.phrase.id