Why can't I set a nullable int to null in a ternary if statement?

The compiler is trying to tell you that it can't determine what type the expression should evaluate as. There's no implicit conversion between null and int hence the error message You need to tell the compiler that the expression should evaluate as an int? There is an implicit conversion between int?

And int or between null and int? So either of these should work: int? X = true?

(int? )null : 0; int? Y = true?

Null : (int? )0.

The compiler tries to evaluate the right-hand expression. Null is null and the 0 is an int literal, not int?. The compiler is trying to tell you that it can't determine what type the expression should evaluate as.

There's no implicit conversion between null and int, hence the error message. You need to tell the compiler that the expression should evaluate as an int?. There is an implicit conversion between int?

And int, or between null and int? , so either of these should work: int? X = true?(int?)null : 0; int?

Y = true? Null : (int?)0.

You need to use the default() keyword rather than null when dealing with ternary operators. Example: int? I; I = (true?

Default(int? ) : 0); HTH!

Null : 0) becomes a function in a way. This function needs a return type. When the compiler needs to figure out the return type it can't.

This works int? I; I = (true? Null : (int?

)0).

Null is null and the 0 is an int literal, not int?. The compiler is trying to tell you that it can't determine what type the expression should evaluate as. There's no implicit conversion between null and int, hence the error message.

You need to tell the compiler that the expression should evaluate as an int?. There is an implicit conversion between int? And int, or between null and int?

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions