C# Error
CS1750 – A value of type ‘{0}’ cannot be used as a default parameter because there are no standard conversions to type ‘{1}’
Reason for the Error & Solution
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 (e.g., public static implicit operator S(int n) => ...)
will not correct this error because that does not add a standard conversion.