Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
121 views
in Technique[技术] by (71.8m points)

c# - Nullable<int> vs. int? - Is there any difference?

Apparently Nullable<int> and int? are equivalent in value. Are there any reasons to choose one over the other?

Nullable<int> a = null;
int? b = null;
a == b; // this is true
Question&Answers:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

No difference.

int? is just shorthand for Nullable<int>, which itself is shorthand for Nullable<Int32>.

Compiled code will be exactly the same whichever one you choose to use.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...