I am a C++ user and now trying to use c#.
In c++ taking input from the user was fun (just >>) and supported all the types. So was for the files. But in c# it is too complex, as I can take only strings. Then I have to manipulate it for later use.
And if I want to take multiple inputs in same line separated by whitespaces, it become more complex as I have to go for string splitting. Then conversion…
May be it is for error handling and safe code. But I am disappointed with C# anyway.
You are all expert guys here. Is there any easy way?
As far as I’m aware, you have to do it the hard way. (On the bright side though, the hard way is simpler than it’d be in C++ ;))
Console.OpenStandardInput() does give you the input stream, so it can be treated the same as files, but you’ll have to do the string splitting yourself if you need that. Of course, C# has a nice Regex library that may help here.
T.TryParse (where T is int, float, whichever type you want to read) should let you convert the string to those types.