I know maybe this not a good way to create class but I just wondered why if else working but conditional
operator not and need implicit conversion
static void Main(string[] args)
{
dynamic myclass;
if (true) /*some condition*/
{
myclass = new ClassA();
}
else
{
myclass = new ClassB();
}
myclass = true /*some condtion*/ ? new ClassA() : new ClassB(); //this line gives an error
//Type of conditional expression cannot be determined because there is no implicit conversion between 'ConsoleApp4.ClassA' and 'ConsoleApp4.ClassB'
}