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 206 views
1 answer 204 views
1 answer 206 views
2 answers 291 views
1 answer 287 views
...