I am going through this WPF tutorial http://blogs.vertigo.com/personal/alanl/Blog/Lists/Posts/Post.aspx?ID=18 and I have a question about the CountToFontSizeConverter section of the tutorial. Could someone please explain the return statement to me i.e
return ((minFontSize + count + increment) < maxFontSize) ?
(minFontSize + count + increment) : maxFontSize;
I understand it’s a conditional but the syntax looks rather bespoke. If possible could someone re-write this in a simpler way? Thanks
Not sure what you mean by “somewhat bespoke” but it’s worth breaking down.
Original:
Broken down:
Better approach – far more readable:
In general, you can usually replace an expression of the form
with
assuming that
aandbare of numeric types. It’s not always the case, but it’s a good starting point.