Is there a way to avoid casting to a non-string type when reading data from a text file containing exclusively integer values separated by integer markers (‘0000’ for example) ?
(Real-Life example : genetic DNA sequences, each DNA marker being a digit sequence.)
EDIT :
Sample data : 581684531650000651651561156843000021484865321200001987984948978465156115684300002148486532120000198798400009489786515611568430000214848653212000019879849480006516515611684531650000651651561156843000021 etc…
Unless I use a binary writer and read bytes, rather than text (because that is how data written at first),
I think this a funky idea, so “NO” would be the straight answer for this.
Just wanted to get a definitive confirmation to that here, just to be definitely sure.
I welcome any intermediate solution to write/read this kind of data efficiently without having to code a custom reader GUI to display it outside my app, intelligibly (in some generic reader/viewer).
rather then just casting, you really should use the
.TryParse(...)method(s) of the types you are trying to read. This is a much more type-safe solution.And to answer your question, other then using a binary file, there is not (to my knowledge) a way to do this without casting (or using the TryParse methods)