Random repetitive problems in a short time

Source: Internet
Author: User

First of all, I saw the solution in that article:

http://dl.download.csdn.net/down10/20141103/4b173214e41ff3207305c2470524b0f3.zip?response-
content-disposition=attachment%3bfilename%3d%e8%84%9a%e6%9c
%ac.zip&ossaccesskeyid=9q6nvzojgowbj4q1&expires=1454872774&signature=hkefociyztemjgo9sckmje
Ixmg4%3d

Method In fact no difference is just code because of the big God Hand, resulting in code size is not clear, new people see also have to change a lot, just like me! So write the code again. One is for the convenience of everyone is also for fear of forgetting, after all, not used/

The focus is on the GUID: the globally unique identifier (guid,globally unique Identifier) is a numeric identifier generated by the algorithm with a binary length of 128 bits. GUIDs are primarily used in networks or systems that have multiple nodes, multiple computers. Ideally, no computer or computer cluster will generate two identical GUIDs. The total number of GUIDs reaches 2^128 (3.4x10^38), so the probability of randomly generating two identical GUIDs is very small, but not 0. The term GUID also sometimes refers to Microsoft's implementation of the UUID standard.

Ideally, no computer or computer cluster will generate two identical GUIDs. The probability of randomly generating two identical GUIDs is very small, but not 0. Therefore, the algorithm used to generate the GUID usually adds non-random parameters (such as time) to ensure that this repetition does not occur.
1         //declare a static integer variable through his changes after the test feeling can be a random number no longer close (that is, the random number is different but close)2          Private Static intRandomcount =0;3          /// <summary>4          ///the seed is calculated using the GUID hash value, the current time ticks, and the counter multiplication to generate the rand variable. 5          /// </summary>6          Static floatCreaterandomint ()7          {8randomcount++;9              //s instantiates a GUID classTenGUID GUID =Guid.NewGuid (); One  A              intKey1 =GUID. GetHashCode (); -              //Summary: Gets the number of ticks that represent the date and time of this instance.  -              //return Result: The number of ticks that represent the date and time of this instance. The value is between DateTime.MinValue.Ticks and DateTime.MaxValue.Ticks the              //between.  -              intKey2 =unchecked((int) DateTime.Now.Ticks); -  -              intSeed =unchecked(Key1 * Key2 *randomcount); +              //Initializes a new instance of the System.Random class with the specified seed value.  -              //Seed: A number used to calculate the starting value of a pseudo-random number sequence. If a negative number is specified, its absolute value is used.  +              //This guarantees rand's differences. ARandom Rand =NewRandom (seed); at              floatNewrand = Rand. Next (0, -); -              returnNewrand; -}

Random repetitive problems in a short time

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.