NGWS SDK Documentation  

This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!

Compiler Error CS0172

Type of conditional expression can't be determined because 'type1' and 'type2' both implicitly convert to each other

In a conditional statement, the types on either side of the : operator have to be convertible. Plus, there cannot be mutual conversion routines; you only need one conversion.

public class Square {

   public class Circle {
      public static implicit operator Circle(Square aa) {
         return null;
      }

      public static implicit operator Square(Circle aa)   {
      // changing this declaration to use explicit resolves this error
      // public static explicit operator Square(Circle aa) {
         return null;
      }
   }   
   public static void Main() {
      Circle aa = new Circle();
      Square ii = new Square();
      object o = (1 == 1) ? aa : ii;   // CS0172
      // the following cast would resolve this error
      // (1 == 1) ? aa : (Circle)ii;   
   }
}