Le code C# ci-dessous:Pourquoi est-ce que je ne peux pas définir un int nullable à null dans une instruction if ternaire?
int? i;
i = (true ? null : 0);
me donne l'erreur:
Type of conditional expression cannot be determined because there is no implicit conversion between '<null>' and 'int'
Si pas valable? Qu'est-ce que j'oublie ici?
Ceci est un doublon de http://stackoverflow.com/questions/2450866 qui était à son tour un duplicata de http://stackoverflow.com/questions/858080. Voir http://stackoverflow.com/questions/2215745/conditional-operator-cannot-cast-implicitly/2215959#2215959 pour une analyse du problème. –