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

This C# program calculates and displays an upper triangular matrix based on user input. Problem Statement: The program takes the...
This C# program serves as a demonstration of bitwise operators, which are fundamental operators used for manipulating individual bits in...
This C# program is designed to interchange or swap the columns of a matrix. A matrix is a two-dimensional array...