You can use the ternary conditional operator. Syntax:
condition ? (statement if true) : (statement if false);
In your case:
ratio = (input.w <= input.h) ? (input.h/input.w) : (input.w/input.h);
EDIT:
It is not faster than your decision, just faster to write. I would advise against using:
var ratio = Math.Max(input.w, input.h) / Math.Min(input.w, input.h)
This will compare numbers twice (once in Math.Max, once in Math.Min) and will be slower.
source share