-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[API Proposal]: Convenient integers reading #74489
Comments
I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label. |
Tagging subscribers to this area: @dotnet/area-system-io Issue DetailsBackground and motivationC# doesn't have an API to read rows of integers from the console nicely. One of the solutions is: var array = Console.ReadLine()!.Split(' ', StringSplitOptions.RemoveEmptyEntries);
array = Array.ConvertAll(array, Int32.Parse); Such a code is necessary for solving problems at codeforces or olympiads. API Proposalnamespace System.IO;
public static class ReaderExtensions
{
public static Int32 ReadInt32(this TextReader reader) { throw null; }
// methods for other types
} API Usagevar array = new int[10];
for (var i = 0; i < 10; i++)
array[i] = Console.In.ReadInt32(); Alternative DesignsC++ operatorsint arr[10];
for (int i = 0; i < 10; i++)
std::cin >> arr[i]; Java's
|
Author: | vorotynsky |
---|---|
Assignees: | - |
Labels: |
|
Milestone: | - |
Related: #64621, which proposes a different API with the same goal. |
Hi @vorotynsky Thank you for your proposal. Since #64621 was opened first and includes proposal for other types as well I am going to close this issue as a duplicate. Please follow #64621 for updates. |
Background and motivation
C# doesn't have an API to read rows of integers from the console nicely.
One of the solutions is:
Such a code is necessary for solving problems at codeforces or olympiads.
API Proposal
API Usage
Alternative Designs
C++ operators
Java's
Scanner
Text format
C has function
scanf
, and F#, Go has the same API.C# can adopt it like this:
Just read a word
Risks
No response
The text was updated successfully, but these errors were encountered: