top of page
  • Writer: VC Healy
    VC Healy
  • Jan 12, 2021
  • 1 min read

After writing a C# console app for a calculator I thought I should give this a try.



 
 
  • Writer: VC Healy
    VC Healy
  • Jan 11, 2021
  • 1 min read

Found a simple console app for checking the longest word in a string. I made some changes to the code to make it a little neater.


Rewrote this to find the shortest word.


Rewrote the code to allow the user to choose whether to choose the Longest or the shortest word. This code also has a multi-use statement. Allowing the user to re-run the code.

If the string under test was changing as in web scrapes. Then this could be the base class.







 
 
  • 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.



 
 

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

bottom of page