Get the maximum of the absolute values ​​returning the signed value

Supposing I have a class

Public Class Foo
Property fooProp1 as Single
Property fooProp2 as Single
Property fooProp3 as Single
End Class

to find the absolut maximum of a property (which contains positive or negative values) in a Collection(Of Foo) I can do:

Collection.Max(Function(x As foo) Math.Abs(x.fooProp1))

and it returns the greater absolute value WITHOUT sign.

The question is how can I do to get the number WITH sign?

Thanks in advance. RG

Math.Abs will always return an unsigned value (the actual meaning of Absolute).

The get the value of a property you need only to READ it.

To get a MAX or MIN, you MUST compare values, like this:

dim x as integer = foo.property
dim y as integer = last_foo_property (or anything else)

Minimum = Math.Min(x,y)
Maximum = Math.Max(x,y)

But, if are trying to get the lower and upper values of a collection, you may utilize:

MaxValue = Collection.Find(Collection, Function(Z) (Z > BiggerValue))

MinValue = Collection.Find(Collection, Function(Z) (Z < LowerValue))

where these values are gotten before the call.

Another way is to make a SORT and get the first and the last values...