首页 > 代码库 > 自学C#记录—文本操作—取随机字母

自学C#记录—文本操作—取随机字母

        /// <summary>          /// 取随机字母          /// </summary>          /// <param name="Count">字母个数</param>          /// <returns>返回指定个数的随机字母串</returns>         public static string GetRandomLetter(int Count)        {            String[] s = { "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z" };            StringBuilder stb = new StringBuilder();            Random rd = new Random(Guid.NewGuid().GetHashCode());            for (int i = 0; i < Count; i++)            {                stb.Append(s[rd.Next(26)]);            }            return stb.ToString();        }

 

自学C#记录—文本操作—取随机字母