Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- namespace switchStatementExample
- {
- public class Program
- {
- public static void Main()
- {
- // declare a string to scramble, an empty list<char>.
- // then add the chars of that string to the list
- string word = "apple";
- List<char> letterArray = new List<char>();
- letterArray.AddRange(word);
- Random random = new Random();
- // randomly order the letters in the list<char>
- for(int i = letterArray.Count; i > 0; i --)
- {
- int index = random.Next(letterArray.Count);
- char currentChar =letterArray[index];
- Console.Write(currentChar);
- letterArray.RemoveAt(index);
- }
- // output similar to
- // aplep
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement