I assumed this would be a simple job. Off I went to Google only to find convoluted methods which still only worked in “most cases”. I am a little surprised by this.

Obviously if you can control the expected format this is simple. My situation was different as someone else set that previously. All I knew was line 1 is a whole positive number.

I was recently sent an executable that had had its file extension changed to .txt. – don’t ask why i don’t know. This crashed my little parsing program. I had been using try.parse to validate a number. The number of chars in the line were too high giving an out of bounds.

This left me with a question… should I stop using try.parse in favour of a try catch block. More experiments to come. But what if i just wanted to ensure a text editor didn’t display gibberish?

Written by Sara Payne

Student of Computer Science at The University Of Hull and small business owner.

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.