Random code generated

This code generated a random string code

public static class GenerateCode
    {
        private static string source = "ABCDEFGHIJKLMNOPRSTUVYZabcdefghijklmnoprstyvyz1234567890";
        private static Random random = new Random();

        public static string Generate(int size)
        {
            string generatedCode = new string(
            Enumerable.Repeat(source, size)
            .Select(s => s[random.Next(s.Length)])
            .ToArray());

            return generatedCode;
        }
    }

#csharp, #generate-code, #random, #random-code

Advertisements