C# - Generatore di lettere Random 24/02/2011 22:23:15
using System;

static class RandomLetter
{
static Random _random = new Random();
public static char GetLetter()
{
// This method returns a random lowercase letter.
// ... Between 'a' and 'z' inclusize.
int num = _random.Next(0, 26); // Zero to 25
char let = (char)('a' + num);
return let;
}
}

class Program
{
static void Main()
{
// Get random lowercase letters.
Console.WriteLine(RandomLetter.GetLetter());
Console.WriteLine(RandomLetter.GetLetter());
Console.WriteLine(RandomLetter.GetLetter());
Console.WriteLine(RandomLetter.GetLetter());
Console.WriteLine(RandomLetter.GetLetter());
}
}

--- Output of the program ---

i
q
f
t
o
12345
Copyright (c) 2010 ilcorsaronero. All rights reserved.