Explanation on Integer.MAX_VALUE and Integer.MIN_VALUE to find min and max value in an array

but as for this method, I don’t understand the purpose of Integer.MAX_VALUE and Integer.MIN_VALUE. By starting out with smallest set to Integer.MAX_VALUE and largest set to Integer.MIN_VALUE, they don’t have to worry later about the special case where smallest and largest don’t have a value yet. If the data I’m looking through has a 10 …

Read more

Format Number like Stack Overflow (rounded to thousands with K suffix)

Like this: (EDIT: Tested) static string FormatNumber(int num) { if (num >= 100000) return FormatNumber(num / 1000) + “K”; if (num >= 10000) return (num / 1000D).ToString(“0.#”) + “K”; return num.ToString(“#,0”); } Examples: 1 => 1 23 => 23 136 => 136 6968 => 6,968 23067 => 23.1K 133031 => 133K Note that this will …

Read more