开发者

Greater number among number stored in a set of variables

I have 10 number in a set a variables. (say: 25, 33, 11,开发者_StackOverflow中文版 4, 3.................) I want to get the biggest number in a message.

How do I get it? Thanks Furqan


This looks like a homework question. So, if you'll forgive me, I'm not going to give a direct answer.

What you might want to look at is Math.Max. You loop over the numbers and store the result of each Math.Max and the value stored at the end is the largest number that you have.


Let's assume the numbers are passed as an array (or any Enumerable such as List), this code will do the work for you

Dim numbers() = New Integer(){25, 33, 11, 4, 3}
Dim max = numbers.Max()

MsgBox("Maximum number is: " & max)

I seriously think this is a homework though.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜