0
votes

in "7.13 The null coalescing operator" of C# 4.0 spec, it says

Otherwise, if b has a type B and an implicit conversion exists from a to B, the result type is B.

By my understand, it should be from A0 to B(A0 is the underlying type of A if A is a nullable type, or A otherwise).

int? a=null;
long b=5;

then type for a??b is long, because an implicit conversion exists from int(namely A0) to long.

please help confirm whether my view is correct.

1
What is your question about this?Rory McCrossan
just request help for confirming whether my view is correct.Vince
Are you saying you think there is an error in the spec here? Reading that whole section (not just the line you pasted) I don't think so, this seems correct to me.Steve
no implicit conversion from int? to long. but one from int to long exists. I have found it's "from A0 to B" in C#3.0. it maybe a typo in C#4.0Vince

1 Answers

1
votes

in C#3.0 it says:

Otherwise, if an implicit conversion exists from A0 to B, the result type is B.

in my guess, it may be a typo in C#4.0.