Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Approach 1
- using System;
- namespace RandomLetters
- {
- class Program
- {
- static void Main(string[] args)
- {
- Random random = new Random();
- for (int i = 0; i <10; i++)
- {
- int randomLetter = random.Next(65, 91);
- Console.WriteLine((char)randomLetter);
- }
- Console.ReadLine();
- }
- }
- }
- //Approach 2
- using System;
- namespace RandomLetters
- {
- class Program
- {
- static void Main(string[] args)
- {
- Random random = new Random();
- // create a new array called alphabet, and assign it the value of the string alphabet.ToCharArray
- char[] alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ".ToCharArray();
- for(int i = 0; i < 10; i ++)
- {
- int randomLetter = random.Next(0, alphabet.Length);
- Console.WriteLine(alphabet[randomLetter]);
- }
- Console.ReadLine();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement