Advertisement
Guest User

Untitled

a guest
Feb 19th, 2019
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.52 KB | None | 0 0
  1.     static class EnumerableExtensions
  2.     {
  3.         public static double Max(this IEnumerable<double> source)
  4.         {
  5.             using (var en = source.GetEnumerator())
  6.             {
  7.                 if (!en.MoveNext())
  8.                     throw new ArgumentException("empty seq");
  9.                 var currmax = en.Current;
  10.                 while (en.MoveNext())
  11.                     if (en.Current > currmax)
  12.                         currmax = en.Current;
  13.                 return currmax;
  14.             }
  15.         }
  16.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement