using System;
class Program
{
class Foo
{
public Foo( )
{
Console.WriteLine ( "Building Foo" ) ;
}
public int Bar
{
get
{
Console.WriteLine ( "Getting Foo.Bar" ) ;
return 0 ;
}
set
{
Console.WriteLine ( "Setting Foo.Bar: boom!" ) ;
throw new Exception( ) ;
}
}
}
static Foo foo2;
static Foo foo
{
get
{
Console.WriteLine ( "Getting foo" ) ;
return foo2;
}
set
{
Console.WriteLine ( "Setting foo" ) ;
foo2 = value;
}
}
static void Main( string[ ] args)
{
try
{
foo = new Foo { Bar = 100 } ;
}
catch ( Exception ex)
{
Console.WriteLine ( "Exception: {0}" , ex) ;
}
Console.WriteLine ( "Finished try/catch" ) ;
Console.WriteLine ( "foo initialized: {0}" , foo != null ) ;
}
}
dXNpbmcgU3lzdGVtOwoKY2xhc3MgUHJvZ3JhbQp7CiAgICBjbGFzcyBGb28KICAgIHsKICAgICAgICBwdWJsaWMgRm9vKCkKICAgICAgICB7CiAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCJCdWlsZGluZyBGb28iKTsKICAgICAgICB9CgogICAgICAgIHB1YmxpYyBpbnQgQmFyCiAgICAgICAgewogICAgICAgICAgICBnZXQKICAgICAgICAgICAgewogICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIkdldHRpbmcgRm9vLkJhciIpOwogICAgICAgICAgICAgICAgcmV0dXJuIDA7CiAgICAgICAgICAgIH0KCiAgICAgICAgICAgIHNldAogICAgICAgICAgICB7CiAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiU2V0dGluZyBGb28uQmFyOiBib29tISIpOwogICAgICAgICAgICAgICAgdGhyb3cgbmV3IEV4Y2VwdGlvbigpOwogICAgICAgICAgICB9CiAgICAgICAgfQogICAgfQoKICAgIHN0YXRpYyBGb28gZm9vMjsKCiAgICBzdGF0aWMgRm9vIGZvbwogICAgewogICAgICAgIGdldAogICAgICAgIHsKICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIkdldHRpbmcgZm9vIik7CiAgICAgICAgICAgIHJldHVybiBmb28yOwogICAgICAgIH0KCiAgICAgICAgc2V0CiAgICAgICAgewogICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiU2V0dGluZyBmb28iKTsKICAgICAgICAgICAgZm9vMiA9IHZhbHVlOwogICAgICAgIH0KICAgIH0KCiAgICBzdGF0aWMgdm9pZCBNYWluKHN0cmluZ1tdIGFyZ3MpCiAgICB7CiAgICAgICAgdHJ5CiAgICAgICAgewogICAgICAgICAgICBmb28gPSBuZXcgRm9vIHsgQmFyID0gMTAwIH07CiAgICAgICAgfQogICAgICAgIGNhdGNoIChFeGNlcHRpb24gZXgpCiAgICAgICAgewogICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiRXhjZXB0aW9uOiB7MH0iLCBleCk7CiAgICAgICAgfQoKICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiRmluaXNoZWQgdHJ5L2NhdGNoIik7CgogICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCJmb28gaW5pdGlhbGl6ZWQ6IHswfSIsIGZvbyAhPSBudWxsKTsKICAgIH0KfQo=