How to return single line ternary operator (if shorthand) from function in VB.NET

1 Answer

0 votes
Public Class Program 
    Public Shared Function mymax(a As Integer, b As Integer) As Integer
        return If (a > b, a, b)
    End Function
    
    Public Shared Sub Main()
        Console.WriteLine(mymax(23, 95)) 
        Console.WriteLine(mymax(mymax(23, 95), 100)) 
    End Sub
End Class



' run:

' 95
' 100

 



answered Jun 7, 2019 by avibootz

Related questions

1 answer 215 views
1 answer 209 views
1 answer 212 views
2 answers 297 views
1 answer 296 views
...