Shortest Word from the Longest
- VC Healy
- Jan 11, 2021
- 1 min read
This little code snip started life as a Longest Word in an array script.
The script didn't close at the end of the script, it was waiting for a keypress from the user.
Therefore I thought this would be good to have a play with.
First, I added in the 'static System.Console;' I will add this to all the C# code I write as standard as it saves any repetitive writing of 'Console.'
Added 'Environment.Exit(0)' to close the script.
Pulled out the array to a static outside the Main().
Changed the code to look at the Shortest word in the array rather than the Longest.
A final touch, clear the console to give a clean look to the answer for the user.

Comments