vb.net - 你如何用 vb.net 在 5 中找到最大的数?

标签 vb.net find max

这是在 3 中查找最大值的代码,但我想要在 5 中查找最大值的代码:

Dim a, b, c As Integer

a = InputBox("enter 1st no.") 
b = InputBox("enter 2nd no.") 
c = InputBox("enter 3rd no.")

If a > b Then 
    If a > c Then 
        MsgBox("A is Greater") 
    Else 
        MsgBox("C is greater") 
    End If 
Else 
    If b > c Then 
        MsgBox("B is Greater") 
    Else 
        MsgBox("C is Greater")
    End If 
End If 

最佳答案

将值放入数组并使用 the Max function on IEnumerable :

'Requires Linq for Max() function extension
Imports System.Linq
'This is needed for List
Imports System.Collections.Generic

' Create a list of Long values. 
Dim longs As New List(Of Long)(New Long() _
                                   {4294967296L, 466855135L, 81125L})

' Get the maximum value in the list. 
Dim max As Long = longs.Max()

' Display the result.
MsgBox("The largest number is " & max)

' This code produces the following output: 
' 
' The largest number is 4294967296

关于vb.net - 你如何用 vb.net 在 5 中找到最大的数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15644712/

相关文章:

vb.net - VB.NET将Select Case语句堆叠在一起,例如在Switch C#/Java中

mysql - VB.Net 删除 DataGridView MySql 中选定的行

python - 分析数据集的增减

mysql - 从多列中获取不同的最大值

c# - 为 XNA 创建我自己的 FBX 文件? (在 3ds max 中)

javascript - 单击asp图像按钮时如何避免回发?

c# - 如何同步运行延续任务?

linux - 在linux中递归运行命令

linux - 查找、替换或插入 - 命令行

javascript - jquery 可点击行 : how to find the value i need in ${this}