How to develop an extension method that may return random character(single character) from alphabet (a,b,….z).
public static char RandomLetter(this char randomchar)
{
}
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
An extension method is the wrong tool here, since a random letter from the alphabet isn’t related to an input letter (or am I missing something here?).
Edit (responding to comments):
You could make it into an extension method on the
Randomtype:(I chose not to call it
NextLetterOfTheAlphabetsince it obviously should be random)Thread-safety could be added by synchronizing on a private variable of the class that implements these method. However I think the whole locking process is more CPU taxing than pulling off a random number: