> For the complete documentation index, see [llms.txt](https://andreyakinshin.gitbook.io/problembookdotnet/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://andreyakinshin.gitbook.io/problembookdotnet/ru/valuetypes/boxing-p.md).

# «Boxing» (Задача)

Что выведет следующий код?

```csharp
struct Foo
{   
  int value;
  public override string ToString()
  { 
    if (value == 2)
      return "Baz";
    return (value++ == 0) ? "Foo" : "Bar";
  }
}
void Main()
{ 
  var foo = new Foo();
  Console.WriteLine(foo);
  Console.WriteLine(foo);
  object bar = foo;
  object qux = foo;
  object baz = bar;
  Console.WriteLine(baz);
  Console.WriteLine(bar);
  Console.WriteLine(baz);
  Console.WriteLine(qux);
}
```

[Решение](/problembookdotnet/ru/valuetypes/boxing-s.md)
