P
P
ProblemBook.NET
Search…
P
P
ProblemBook.NET
ProblemBook.NET
LANGS
Задачник.NET
ProblemBook.NET
Oop
Strings
Linq
Multithreading
ValueTypes
“StructLayout” (Problem)
“MutableProperty” (Solution)
“Boxing” (Solution)
“MutableProperty” (Problem)
“Boxing” (Problem)
“Enumerator” (Solution)
“Enumerator” (Problem)
“StructLayout” (Solution)
Math
Summary
Introduction
Attribution-NonCommercial-NoDerivatives 4.0 International
Powered By
GitBook
“Boxing” (Problem)
What will the following code display?
1
struct
Foo
2
{
3
int
value
;
4
public
override
string
ToString
()
5
{
6
if
(
value
==
2
)
7
return
"Baz"
;
8
return
(
value
++
==
0
)
?
"Foo"
:
"Bar"
;
9
}
10
}
11
void
Main
()
12
{
13
var
foo
=
new
Foo
();
14
Console
.
WriteLine
(
foo
);
15
Console
.
WriteLine
(
foo
);
16
object
bar
=
foo
;
17
object
qux
=
foo
;
18
object
baz
=
bar
;
19
Console
.
WriteLine
(
baz
);
20
Console
.
WriteLine
(
bar
);
21
Console
.
WriteLine
(
baz
);
22
Console
.
WriteLine
(
qux
);
23
}
Copied!
Solution
Previous
“MutableProperty” (Problem)
Next
“Enumerator” (Solution)
Last modified
3yr ago
Copy link