Random ro = new Random(); //声明对象
int iResult;//随机数
iResult = ro.Next(1, max);//取一个从1到max的整数
生成N位
public static string RandCode(int N){char[] arrChar = new char[] { \'0\', \'1\', \'2\', \'3\', \'4\', \'5\', \'6\', \'7\', \'8\', \'9\' };StringBuilder num = new StringBuilder();Random rnd = new Random(Guid.NewGuid().GetHashCode());for (int i = 0; i < N; i++){num.Append(arrChar[rnd.Next(0, arrChar.Length)].ToString());}return num.ToString();}
爱站程序员基地
![(原创)[C#] 一步一步自定义拖拽(Drag&Drop)时的鼠标效果:(一)基本原理及基本实现-爱站程序员基地](https://aiznh.com/wp-content/uploads/2022/07/20220721231016-62d9dcd85c40b-220x150.gif)

