P
P
ProblemBook.NET
Search…
P
P
ProblemBook.NET
ProblemBook.NET
LANGS
Задачник.NET
ProblemBook.NET
Oop
Strings
Linq
“YieldExceptionYield” (Problem)
“QueryAfterRemove” (Problem)
“ClosureAndVariable” (Problem)
“QueryWithInc” (Solution)
“QueryWithInc” (Problem)
“LifeAfterYield” (Solution)
“LifeAfterYield” (Problem)
“EnumerableToArray” (Solution)
“EnumerableToArray” (Problem)
«YieldExceptionYield» (Solution)
“ExceptionYieldYield” (Solution)
“ClosureAndForeach” (Solution)
“TryYieldFinally” (Problem)
“ClosureAndFor” (Solution)
“ExceptionYieldYield” (Problem)
“YieldExceptionYield” (Solution)
“ClosureAndForeach” (Problem)
“ClosureAndVariable” (Solution)
“QueryAfterRemove” (Solution)
“ClosureAndFor” (Problem)
Multithreading
ValueTypes
Math
Summary
Introduction
Attribution-NonCommercial-NoDerivatives 4.0 International
Powered By
GitBook
“QueryWithInc” (Solution)
Answer
1
Inc: 0
2
Inc: 1
3
Number: 2
4
Inc: 2
5
Inc: 3
6
Number: 4
Copied!
Explanation
An imperative version of the code is as follows:
1
var
numbers
=
new
[]
{
0
,
1
,
2
,
3
,
4
,
5
,
6
,
7
,
8
,
9
};
2
var
takenAmount
=
0
;
3
for
(
int
i
=
0
;
i
<
numbers
.
Length
;
i
++
)
4
{
5
var
number
=
numbers
[
i
];
6
Console
.
WriteLine
(
"Inc: "
+
number
);
7
var
number2
=
number
+
1
;
8
if
(
number2
%
2
==
0
)
9
{
10
Console
.
WriteLine
(
"Number: "
+
number2
);
11
takenAmount
++
;
12
if
(
takenAmount
==
2
)
13
break
;
14
}
15
}
Copied!
Problem
Previous
“ClosureAndVariable” (Problem)
Next
“QueryWithInc” (Problem)
Last modified
3yr ago
Copy link
Contents
Answer
Explanation