diff options
author | Jb Evain <jbevain@gmail.com> | 2008-05-09 17:28:21 +0400 |
---|---|---|
committer | Jb Evain <jbevain@gmail.com> | 2008-05-09 17:28:21 +0400 |
commit | 7dca6ed377d85e850afd16e6ee36a47647734b80 (patch) | |
tree | 9fa995a3cc32b187fbb1c0eb7c77d0409218ee31 /mcs/class | |
parent | ee34b4c89ba7e546752f9485cb45333eae43a652 (diff) |
small cleanup
svn path=/trunk/mcs/; revision=102865
Diffstat (limited to 'mcs/class')
-rw-r--r-- | mcs/class/System.Core/System.Linq/Enumerable.cs | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/mcs/class/System.Core/System.Linq/Enumerable.cs b/mcs/class/System.Core/System.Linq/Enumerable.cs index 53f2bc77be5..c89a1d2ac07 100644 --- a/mcs/class/System.Core/System.Linq/Enumerable.cs +++ b/mcs/class/System.Core/System.Linq/Enumerable.cs @@ -375,10 +375,9 @@ namespace System.Linq if (comparer == null) comparer = EqualityComparer<TSource>.Default; - foreach (TSource e in source) { - if (comparer.Equals (e, value)) + foreach (var element in source) + if (comparer.Equals (element, value)) return true; - } return false; } @@ -930,7 +929,7 @@ namespace System.Linq { Check.Source (source); - TSource [] array = source as TSource []; + var array = source as TSource []; if (array != null) return array.LongLength; @@ -1547,7 +1546,7 @@ namespace System.Linq { Check.Source (source); - IList<TSource> list = source as IList<TSource>; + var list = source as IList<TSource>; if (list == null) list = new List<TSource> (source); @@ -1712,7 +1711,6 @@ namespace System.Linq return source.Single (PredicateOf<TSource>.Always, Fallback.Default); } - public static TSource SingleOrDefault<TSource> (this IEnumerable<TSource> source, Func<TSource, bool> predicate) { Check.SourceAndPredicate (source, predicate); @@ -1954,7 +1952,7 @@ namespace System.Linq static TR Sum<TA, TR> (this IEnumerable<TA> source, Func<TR, TA, TR> selector) { TR total = default (TR); - int counter = 0; + long counter = 0; foreach (var element in source) { total = selector (total, element); ++counter; @@ -2014,7 +2012,7 @@ namespace System.Linq static IEnumerable<TSource> CreateTakeWhileIterator<TSource> (IEnumerable<TSource> source, Func<TSource, bool> predicate) { - foreach (TSource element in source) { + foreach (var element in source) { if (!predicate (element)) yield break; |