项目作者: nminaya

项目描述 :
Generic Random List
高级语言: C#
项目地址: git://github.com/nminaya/RandomList.git
创建时间: 2018-03-21T17:22:40Z
项目社区:https://github.com/nminaya/RandomList

开源协议:MIT License

下载


NuGet version

RandomList

RandomList it’s basically a Collection of items that can be iterated randomly.

Use:

  1. // Creating a RandomList of string
  2. var randomList = new RandomList<string>();
  3. // Adding items
  4. randomList.Add("First");
  5. randomList.Add("Second");
  6. randomList.Add("Third");

Then, when the collection is iterated:

example

The elements are not in the same order in wich they were added. That’s because RandomList randomizes the order of the elements.

Installation:

It is available on Nuget. To install via Package Manager Console:

  1. PM> Install-Package RandomList.Core

Or browsing “RandomList” through NuGet VS VSIX.

Features:

Randomize method:

Having a RandomList, you can randomize the order of the elements again.

  1. var randomList = new RandomList<int>{ 1, 2, 3, 4};
  2. // actual order of elements: 2, 1, 4, 3
  3. //Randomizing
  4. randomList.Randomize();
  5. // new order of elements: 3, 1, 2, 4

GetItemRandomly method:

Having a RandomList, you can get an element randomly.

  1. var randomList = new RandomList<int>{ 1, 2, 3, 4};
  2. // Getting an item
  3. int item = randomList.GetItemRandomly();