當前位置: 首頁>>代碼示例>>C#>>正文


C# Random.NextInt64方法代碼示例

本文整理匯總了C#中System.Random.NextInt64方法的典型用法代碼示例。如果您正苦於以下問題:C# Random.NextInt64方法的具體用法?C# Random.NextInt64怎麽用?C# Random.NextInt64使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Random的用法示例。


在下文中一共展示了Random.NextInt64方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: GenerateRandomAccountCollection

        private EntityCollection GenerateRandomAccountCollection()
        {
            var collection = new List<Entity>();
            for (var i = 0; i < 10; i++)
            {
                var rgn = new Random((int)DateTime.Now.Ticks);
                var entity = new Entity("account");
                entity["accountid"] = entity.Id = Guid.NewGuid();
                entity["address1_addressid"] = Guid.NewGuid();
                entity["modifiedon"] = DateTime.Now;
                entity["lastusedincampaign"] = DateTime.Now;
                entity["donotfax"] = rgn.NextBoolean();
                entity["new_verybignumber"] = rgn.NextInt64();
                entity["exchangerate"] = rgn.NextDecimal();
                entity["address1_latitude"] = rgn.NextDouble();
                entity["numberofemployees"] = rgn.NextInt32();
                entity["primarycontactid"] = new EntityReference("contact", Guid.NewGuid());
                entity["revenue"] = new Money(rgn.NextDecimal());
                entity["ownerid"] = new EntityReference("systemuser", Guid.NewGuid());
                entity["industrycode"] = new OptionSetValue(rgn.NextInt32());
                entity["name"] = rgn.NextString(15);
                entity["description"] = rgn.NextString(300);
                entity["statecode"] = new OptionSetValue(rgn.NextInt32());
                entity["statuscode"] = new OptionSetValue(rgn.NextInt32());
                collection.Add(entity);
            }

            return new EntityCollection(collection);
        }
開發者ID:guusvanw,項目名稱:Guus.Xrm,代碼行數:29,代碼來源:GenericXrmServiceTest.cs

示例2: TranspositionTable

        public TranspositionTable()
        {
            tableContent = new HashObject[tableSize];
            System.Random random = new System.Random(DateTime.Now.Millisecond);
            List<Int64> generatedBefore = new List<Int64>();
            turnPlayerA = random.NextInt64();
            turnPlayerB = random.NextInt64();
            playerAMax = random.NextInt64();
            playerBMax = random.NextInt64();
            generatedBefore.Add(turnPlayerA);

            while (generatedBefore.Contains(turnPlayerB)) turnPlayerB = random.NextInt64();
            generatedBefore.Add(turnPlayerB);

            while (generatedBefore.Contains(playerAMax)) playerAMax = random.NextInt64();
            generatedBefore.Add(playerAMax);

            while (generatedBefore.Contains(playerBMax)) playerBMax = random.NextInt64();
            generatedBefore.Add(playerBMax);

            for (int x = 0; x < 21; x++)
            {
                for (int y = 0; y < 20; y++)
                {
                    for (int n = 0; n < 6; n++)
                    {
                        Int64 randomValue = random.NextInt64();
                        while (generatedBefore.Contains(randomValue)) randomValue = random.NextInt64();
                        generatedBefore.Add(randomValue);

                        switch (n)
                        {
                            case 0:
                                emptySpacesKeys[x,y] = randomValue;
                                break;
                            case 1:
                                tilesKeys[x,y] = randomValue;
                                break;
                            case 2:
                                redTailKeys[x,y] = randomValue;
                                break;
                            case 3:
                                redheadKeys[x,y] = randomValue;
                                break;
                            case 4:
                                whiteTailKeys[x,y] = randomValue;
                                break;
                            case 5:
                                whiteHeadKeys[x, y] = randomValue;
                                break;
                        }
                    }
                }
            }
        }
開發者ID:theplaymate,項目名稱:windespacman,代碼行數:55,代碼來源:TranspositionTable.cs

示例3: CanSampleInt64

 public void CanSampleInt64()
 {
     var rnd = new Random();
     rnd.NextInt64();
 }
開發者ID:XiBeichuan,項目名稱:hydronumerics,代碼行數:5,代碼來源:SystemRandomExtensionTests.cs


注:本文中的System.Random.NextInt64方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。