IOStream operator<< Conversion from C++ to C# -


i trying convert old c++ code c# , having difficulty in understanding following code , how can converted c#.

ifstream fin; fin.open(file, ios::nocreate);  if (!fin) {     m_ierrornumber = 1567;     num = 0.0; } else {     (int x = 0; x < count; x++)     {         fin >> num;  //  <==== line problem!!     } };  fin.close(); 

this has different semantics c++ code, should relatively similar:

ienumerable<string> readwhitespaceseparated(string filename) {     using(var lines = file.readlines(filename))     {         return lines.selectmany(line => line.split(new []{' ','\t', '\r', '\n'}, stringsplitoptions.removeemptyentries));     } }  ienumerable<string> readdoubles(string filename) {      return readwhitespaceseparated(filename)          .select(s => double.parse(s, cultureinfo.invariantculture)); } 

then can read count doubles file readdoubles(filename).take(count)


Comments

Popular posts from this blog

c++ - Creating new partition disk winapi -

Android Prevent Bluetooth Pairing Dialog -

VBA function to include CDATA -