Export (0) Print
Expand All
Expand Minimize

Compiler Error CS0173 

Error Message

Type of conditional expression cannot be determined because there is no implicit conversion between 'class1' and 'class2'

Conversions between classes are useful when you want objects of different classes to work with the same code. However, two classes that will work together cannot have mutual and redundant conversions.

To resolve CS0173, verify that there is one and only one implicit conversion between class1 and class2, regardless of which direction the conversion is in and regardless of which class the conversion is in. For more information, see Implicit Numeric Conversions Table (C# Reference) and Conversion Operators (C# Programming Guide)

The following sample generates CS0173:

// CS0173.cs
public class C {}
public class A {}

public class MyClass
   public static void F(bool b)
      A a = new A();
      C c = new C();
      object o = b ? a : c;  // CS0173

   public static void Main()

Community Additions

© 2015 Microsoft