C # Implementation of random Shuffle method

Source: Internet
Author: User
Tags random shuffle shuffle

In this paper, we describe the method of random shuffle in C #. Share to everyone for your reference. The implementation method is as follows:


The code is as follows:

Random Shuffle #region

Int[] INTs = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20};

List<int> list=ints. ToList ();

int[] outs = new INT[20];

Random rand = new Random ();

for (int i = 0; i <; i++)

{

int x = rand. Next (list. Count);

Outs[i] = list[x];

List. RemoveAt (x);

}

Response.Write ("
foreach (int i in outs)

{

Response.Write (i.ToString () + "");

}

#endregion

I hope this article is helpful to everyone's C # programming.

In addition to the Declaration, Running GuestArticles are original, reproduced please link to the form of the address of this article
C # Implementation of random Shuffle method

This address: http://www.paobuke.com/develop/c-develop/pbk23140.html






Related Content C # multi-thread thread class in detail Silverlight implementation of image local amplification effect of C # basics--Variable C # double buffering implementation method (to prevent splash screen)
The difference between dynamic and VAR and the dynamic use of C # Implementation of the taskbar notification window file operation method in C # about the action and Func in C #

C # Implementation of random Shuffle method

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.