each of them have different number that is dependent on the user's input. how to find the smallest number? I usually use math class library in java with min and max method, what to use in C#? Thanx >.< hehe

Member Avatar for iamthwee

set up a simple loop.

Put the five numbers into an array, then go through them.


array = {5,7,3,2,3}

int smallest = 1000000;

For i = 0 to 5
if array < smallest Then
smallest = array

If you used the Min and Max methods from Java, then you can use the System.Math.Max and System.Math.Min methods in C#

Otherwise create a sortable array, get the first and last elements.

Hope that helps,
Jerry

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.