手机
当前位置:查字典教程网 >编程开发 >C#教程 >C#生成随机字符串的实例
C#生成随机字符串的实例
摘要:复制代码代码如下://////生成随机字符串///privateclassRandomStringGenerator{staticreado...

复制代码 代码如下:

/// <summary>

/// 生成随机字符串

/// </summary>

private class RandomStringGenerator

{

static readonly Random r = new Random();

const string _chars = "0123456789";

public static string GetRandomString()

{

char[] buffer = new char[5];

for (int i = 0; i < 5; i++)

{

buffer[i] = _chars[r.Next(_chars.Length)];

}

return new string(buffer);

}

}

【C#生成随机字符串的实例】相关文章:

用C#生成不重复的随机数的代码

C# 设置系统日期格式的方法

C# 合并GriewView相同列的小例子

C#操作EXCEL DataTable转换的实例代码

c# 图片加密解密的实例代码

C#读写操作app.config中的数据应用介绍

c# 匿名方法的小例子

获取字符串中的汉字拼音首字母

c#(Socket)同步套接字代码示例

C#程序最小化到托盘图标操作步骤与实现代码

精品推荐
分类导航