top of page

Shortest Word from the Longest

  • Writer: VC Healy
    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.



 
 
 

Recent Posts

See All
C# Calculator

Written my first C# console app. I had found a simple single calculation console app and I have enhanced it to allow the user to complete...

 
 
 

Comments


© 2020 by Vincent Healy. Proudly created with Wix.com

bottom of page