C# average function without overflow exception
- by Ron Klein
.NET Framework 3.5.
I'm trying to calculate the average of some pretty large numbers.
For instance:
using System;
using System.Linq;
class Program
{
static void Main(string[] args)
{
var items = new long[] { long.MaxValue - 100, long.MaxValue - 200, long.MaxValue - 300 };
try
{
var avg =…