In C++, we can define a custom locale that enables stream object to ignore non-digits in the file, and reads only the integers.
Can we do something similar? How can we efficiently read only integers from a text file? Does C# stream object use locale? If yes, can we define custom locale that we can use with stream object so as to ignore unwanted characters while reading the file?
Here is one example in C++ which efficiently counts frequency of words in a text file: