I need random algorithm with weighing options

前端 未结 3 388
予麋鹿
予麋鹿 2021-02-02 04:38

I have a requirement in my .NET project where I need to select an item from a collection, each item has a Weight (integer from 1 to 10) assigned to it.

I need a random g

3条回答
  •  臣服心动
    2021-02-02 04:48

    Make a list and insert each item in Weight number of times. Then choose a random item from the list.

提交回复
热议问题