本文整理汇总了C#中System.Random.GetHashCode方法的典型用法代码示例。如果您正苦于以下问题:C# Random.GetHashCode方法的具体用法?C# Random.GetHashCode怎么用?C# Random.GetHashCode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Random
的用法示例。
在下文中一共展示了Random.GetHashCode方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: randomXY
public static Tuple<int, int> randomXY(int width, int height) {
Random random = new Random();
int x = random.Next(width);
random = new Random(random.GetHashCode());
int y = random.Next(height);
return new Tuple<int, int>(x, y);
}
示例2: Particle
public Particle(double _x, double _y, IDrawer _drawer)
{
Drawer = _drawer;
m_CoordinatesNew = m_Coordinates = new PairDouble(_x, _y);
Random k = new Random((int) DateTime.Now.ToBinary());
Random r = new Random(k.GetHashCode());
m_Speed = new PairDouble(Miscelaneous.ParticleSpeed * (0.5 - r.NextDouble()), Miscelaneous.ParticleSpeed * (0.5 - r.NextDouble()));
m_Speed.Normalize();
}
示例3: Randomnum
public static string Randomnum(int size)
{
try
{
System.Random ran = new System.Random();
string v_return = ran.GetHashCode().ToString() + ran.Next(99).ToString();
return v_return;
}
catch (Exception ex)
{
throw ex;
}
}