C# Error CS1750 – A value of type ‘{0}’ cannot be used as a default parameter because there are no standard conversions to type ‘{1}’

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.

Leave A Reply

Your email address will not be published. Required fields are marked *

You May Also Like

C# Compiler Error CS0442 – ‘Property’: abstract properties cannot have private accessors Reason for the Error You’ll get this error...
This is a really simple one . Below is a simple example of an enum called “Designation” defined with the...
This blog post explain the usage of the Checked Block in .NET and how you can use them in Visual...