P
P
postya2020-01-14 14:16:27
WPF
postya, 2020-01-14 14:16:27

How to create a percentage drop with a large slope?

I don’t know if I created the title of this topic correctly, but I will try to explain:
there are two lists with elements of the srting type, each with 5 elements:

List<string> questionList = new List<string>();
List<string> sentenceList= new List<string>();

questionList.Add("question1", "question2", "question3", "question4", "question5");
sentenceList.Add("sentence1", "sentence1", "sentence2", "sentence3", "sentence4", "sentence5");

there is a TextBlock at one time a method is called, let's call it This method takes a random number, the random number corresponds to the index of the element in each list and assigns the text to the TextBlock at the index of the random number, and you need to make sure that the chance of falling out is as follows: 80% of the random number falling out on a list of 20% random number hits per list In other words: 80% chance that random text will appear from 20% chance that random text will appear from How to implement this?
TextBlock text= new TextBlock();
GetRandomText
questionList
sentenceList
questionList
sentenceList

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
twobomb, 2020-01-14
@postya

if(random.NextDouble() <= 0.8){
 //из questionList
}
else{
//из sentenceList
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question