当前位置:网站首页>Unity3d C # generates non repeated random numbers in the interval
Unity3d C # generates non repeated random numbers in the interval
2022-06-22 03:00:00 【Dore__】
unity3D C# Generate non repeated random numbers in the interval
private void Start()
{
foreach (var item in GetHashtableRandomNum(5, 0, 6).Values)
{
Debug.Log(item);
}
}
/// <summary>
/// Generate random number
/// </summary>
/// <param name="num"> Number of random numbers </param>
/// <param name="min"> Minimum random number </param>
/// <param name="max"> Maximum random number </param>
/// <returns></returns>
public static Hashtable GetHashtableRandomNum(int num, int min, int max)
{
System.Random random = new System.Random();
Hashtable hashtable = new Hashtable();
for (int i = 0; hashtable.Count < num; i++)
{
int nValue = random.Next(min, max);
if (!hashtable.ContainsValue(nValue) && nValue != min)
{
hashtable.Add(i, nValue);
}
}
return hashtable;
}边栏推荐
- The latest official product of domestic brand oppo! This ppt report! It really refreshes my understanding of it
- Game jam development cycle
- [9. submatrix sum]
- The neo4j skill tree was officially released to help you easily master the neo4j map database
- 【爬虫笔记1】环境搭建和必要工具Selenium
- 图像元数据(Metadata)获取与修改
- Write the processing framework for playing
- Microsoft Internet Explorer was permanently closed on June 15
- June25,2022 PMP Exam clearance manual-4
- An article thoroughly learns to draw data flow diagrams
猜你喜欢

table标签的不规则布局

使用 Neo4j 沙箱学习 Neo4j 图数据科学 GDS
![[percona toolkit] series of Pt table checksum and Pt table sync data verification and repair artifacts](/img/1f/89cc2ec9ae6c967791994acac55c04.png)
[percona toolkit] series of Pt table checksum and Pt table sync data verification and repair artifacts

6、 MySQL data definition language (1)

The latest official product of domestic brand oppo! This ppt report! It really refreshes my understanding of it

Harmonyos Hongmeng uses ORM bee to access database instances

ACL 2022 | multilingual knowledge map reasoning based on self supervised graph alignment

【2. 归并排序】

UnionPay payment return merchant nignx post request 405

The brand, products and services are working together. What will Dongfeng Nissan do next?
随机推荐
Sword finger offer 56 Delete duplicate nodes of the linked list
Is the link of Hengtai securities VIP low commission account opening safe?
图书馆管理系统(PHP期末报告)
【爬虫笔记2】鼠标事件与截图方法、常用攻击方法
Memory hierarchy introduction
PMP pre exam guide on June 25, you need to do these well
[3. binary integer and floating point number]
Force buckle 295 Median data flow
Dernière publication: neo4j Graph Data Science GDS 2.0 et aurads ga
Neo4j 智能供应链应用源代码简析
图数据平台解决方案:集群部署
Sword finger offer 28 Symmetric binary tree
C1-qt idea of realizing simple calculator 2021.10.15
Overview of web framework and program development
PMP reference related agile knowledge
ATM simulation system
Brief analysis of application source code of neo4j intelligent supply chain
Day12QFile2021-09-27
Markdown advanced syntax, marktext compatible
Graphacademy course explanation: Fundamentals of neo4j graph data science