2014-10-04 11:27:48 +01:00
|
|
|
using System;
|
|
|
|
|
|
|
|
struct S
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
class C
|
|
|
|
{
|
2015-01-13 10:44:36 +00:00
|
|
|
public static int ConversionCalled;
|
|
|
|
|
2014-10-04 11:27:48 +01:00
|
|
|
public static implicit operator S (C c)
|
|
|
|
{
|
2015-01-13 10:44:36 +00:00
|
|
|
++ConversionCalled;
|
2014-10-04 11:27:48 +01:00
|
|
|
return new S ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class Program
|
|
|
|
{
|
2015-01-13 10:44:36 +00:00
|
|
|
static C field;
|
|
|
|
|
|
|
|
static int Main ()
|
2014-10-04 11:27:48 +01:00
|
|
|
{
|
|
|
|
C c = new C ();
|
|
|
|
var x = c ?? new S ();
|
2015-01-13 10:44:36 +00:00
|
|
|
|
|
|
|
if (C.ConversionCalled != 1)
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
c = null;
|
|
|
|
x = c ?? new S ();
|
|
|
|
if (C.ConversionCalled != 1)
|
|
|
|
return 2;
|
|
|
|
|
|
|
|
x = field ?? new S ();
|
|
|
|
if (C.ConversionCalled != 1)
|
|
|
|
return 3;
|
|
|
|
|
|
|
|
return 0;
|
2014-10-04 11:27:48 +01:00
|
|
|
}
|
|
|
|
}
|