Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
A value of type cannot be used as a default parameter because there are no standard conversions to type
Example
The following sample generates CS1750:
public struct S
{
public override string ToString() { return "S::ToString"; }
}
public class A
{
public static S Goo(S p = 42) { return p; }
}
There is no standard conversion between int
and the newly declared struct S
. Using an int
compile-time constant to initialize an instance of struct S
results in CS1750. Adding a user-defined conversion operator (for example, public static implicit operator S(int n) => ...
) will not correct this error because that does not add a standard conversion.