logo
  • 教程列表
  • SO官方文档
  • 在 C#中生成随机数
    • 生成随机 int
    • 在给定范围内生成随机 int
    • 一遍又一遍地生成相同的随机数序列
    • 同时创建具有不同种子的多个随机类
    • 生成随机双精度数
    • 生成随机字符
    • 生成一个最大值百分比的数字
  1. StackOverflow 文档
  2. C# Language 教程
  3. 在 C#中生成随机数
  4. 生成随机字符

生成随机字符

Created: November-22, 2018

在 a 和 z 之间生成一个随机字母,通过对给定的数字范围使用 Next() 重载,然后将得到的 int 转换为 char

Random rnd = new Random();
char randomChar = (char)rnd.Next('a','z'); 
//'a' and 'z' are interpreted as ints for parameters for Next()
  • 生成一个最大值百分比的数字
  • 生成随机双精度数

Copyright © 2018. All right reserved

tastones.com 备案号:鲁ICP备18045372号-1

  • 关于我们
  • 免责声明