手机
当前位置:查字典教程网 >编程开发 >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#读写操作app.config中的数据应用介绍

C#获取进程的主窗口句柄的实现方法

c#启动EXE文件的方法实例

c# 应用事务的简单实例

C# 调用Delphi dll 实例代码

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

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

c# 正则指引--字符组

C# 观察者模式实例介绍

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

精品推荐
分类导航