I have two integers, int1
and int2
. I want to check which one is the higher one. How can I do this the best? Is there an C#.NET function for this or do I have to write it myself?
Ofcource I can do something similar to this:
if (int1 < int2)
return int1;
else
return int2;
But I was wondering if there is a more elegant way for doing this?
yours, Bernhard
Math.Max
Usage:
int highest = Math.Max(int1, int2);
It's overloaded for all numeric types.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With