From 2a19ec1d9dbd5d29f2b63c97930fc0bb822ffede Mon Sep 17 00:00:00 2001 From: Atif Aziz Date: Fri, 4 Nov 2022 08:03:30 +0100 Subject: [PATCH] Convert using statements to declarations --- MoreLinq.Test/TraceTest.cs | 10 +++------- MoreLinq/MoreEnumerable.cs | 10 +++------- 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/MoreLinq.Test/TraceTest.cs b/MoreLinq.Test/TraceTest.cs index 0379c2f49..50d07e572 100644 --- a/MoreLinq.Test/TraceTest.cs +++ b/MoreLinq.Test/TraceTest.cs @@ -78,13 +78,9 @@ public void TraceSequenceWithFormatter() static IEnumerable Lines(string str) { - using (var e = _(string.IsNullOrEmpty(str) - ? TextReader.Null - : new StringReader(str))) - { - while (e.MoveNext()) - yield return e.Current; - } + using var e = _(string.IsNullOrEmpty(str) ? TextReader.Null : new StringReader(str)); + while (e.MoveNext()) + yield return e.Current; IEnumerator _(TextReader reader) { diff --git a/MoreLinq/MoreEnumerable.cs b/MoreLinq/MoreEnumerable.cs index ca7938cc7..b80983c3e 100644 --- a/MoreLinq/MoreEnumerable.cs +++ b/MoreLinq/MoreEnumerable.cs @@ -43,13 +43,9 @@ static int CountUpTo(this IEnumerable source, int max) var count = 0; - using (var e = source.GetEnumerator()) - { - while (count < max && e.MoveNext()) - { - count++; - } - } + using var e = source.GetEnumerator(); + while (count < max && e.MoveNext()) + count++; return count; }