Skip to content

Documentation VB.NET Tuple Returns incorrect #3165

Closed

Description

@Styxxy

Submitted pull request #3166

In the code snippers of the documentation for VB.NET about Tuples, I found a small error.

Snippet 3 outputs the original string that is being parsed, rather than the output. It should output the result, as it is also being outputted in snippet 1 (the "original" version, before using the new language features). Another minor thing : the variable name of the "to be parsed string" maybe should match the original version?

Code to be changed:

    Private Sub MethodCallWithTuple()
        ' <Snippet3>
        Dim number As String = "123,456"
        Dim result = ParseInteger(number)
        Console.WriteLine($"{IIf(result.Success, $"Success: {number:N0}", "Failure")}")
        Console.ReadLine()
        '      Output: Success: 123,456
        ' </Snippet3>
    End Sub

Into:

    Private Sub MethodCallWithTuple()
        ' <Snippet3>
        Dim numericString As String = "123,456"
        Dim result = ParseInteger(numericString)
        Console.WriteLine($"{IIf(result.Success, $"Success: {result.Number:N0}", "Failure")}")
        Console.ReadLine()
        '      Output: Success: 123,456
        ' </Snippet3>
    End Sub

Also : sample does not work when using a non-US culture. Maybe specify in Snippet 2 invariant culture info?

Code to be changed:

' <Snippet2>
Imports System.Globalization

Public Module NumericLibrary
    Public Function ParseInteger(value As String) As (Success As Boolean, Number As Int32)
        Dim number As Integer
        Return (Int32.TryParse(value, NumberStyles.Any, Nothing, number), number)
    End Function
End Module
' </Snippet2>

Into:

' <Snippet2>
Imports System.Globalization

Public Module NumericLibrary
    Public Function ParseInteger(value As String) As (Success As Boolean, Number As Int32)
        Dim number As Integer
        Return (Int32.TryParse(value, NumberStyles.Any, CultureInfo.InvariantCulture, number), number)
    End Function
End Module
' </Snippet2>

Activity

  1. svick commented on Sep 18, 2017

    @svick
    Member

    Do you want to create a Pull Request with these changes?

  2. Styxxy commented on Sep 18, 2017

    @Styxxy
    ContributorAuthor

    @svick
    I requested the CLA, however I didn't receive any email yet. Probably will have to sign this at home, as I have a lot of restrictions on my work desktop (for example : getting sources from github is not possible due to firewall / proxy restrictions (unfortunately :( )).

  3. BillWagner commented on Sep 18, 2017

    @BillWagner
    Member

    @Styxxy thanks for submitting PR #3166 and starting the process for the CLA. That PR was small enough that a CLA wasn't necessary. I've already reviewed and merged it.

  4. Styxxy commented on Sep 18, 2017

    @Styxxy
    ContributorAuthor

    @BillWagner Thanks! I opened the issue as I thought that I needed a CLA. But I initiated the process anywa for maybe future pull requests.

  5. added this to the September 2017 milestone on Oct 18, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions