Link to home
Start Free TrialLog in
Avatar of doramail05
doramail05Flag for Malaysia

asked on

Generate a upper case random guid string

below is a method for generate random string based on input length. just that the character in the random string has to be uppercase when return.
public static string GetRandomStringUsingGUID(int length)
    {
        // Get the GUID
        string guidResult = System.Guid.NewGuid().ToString();
        // Remove the hyphens
        guidResult = guidResult.Replace("-", String.Empty);
        
        // Make sure length is valid
        if (((length <= 0)
                    || (length > guidResult.Length)))
        {
            throw new ArgumentException(("Length must be between 1 and " + guidResult.Length));
        }
        // Return the first length bytes
        return guidResult.Substring(0, length);
    }

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Ryan Chong
Ryan Chong
Flag of Singapore image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of doramail05

ASKER

ok