C# – Check number and fill lists – Video

In this video I perform a check whether a number is an integer or a double.

If it is double, it fills out a List<double>(); and if it is integer, it fills out a List<int>(); Once something is entered, which is neither double nor integer, the loop is broken and the program prints the doubles and the integers in separate lines, putting smiles in front of every number.

At the end of the video I use the debugger, because I tought that my code is not working, as far as I was a little tired to notice that I shold break the loop in order to make it work.

This code can be used as a very good example for the usage of try.parse with combination with conditional operator. Enjoy it!

 

The application, created with the abovementioned code is here.

The code of the current article is part of the free Bulgarian C# programming book.