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

LVL 1
doramail05Asked:
Who is Participating?
 
Ryan ChongCommented:
try:

return guidResult.Substring(0, length).ToUpper();
0
 
doramail05Author Commented:
ok
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.