开发者

Greater number among number stored in a set of variables

开发者 https://www.devze.com 2023-01-24 22:05 出处:网络
I have 10 number in a set a variables. (say: 25, 33, 11,开发者_StackOverflow中文版 4, 3.................)

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

精彩评论

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

关注公众号