Nullable Method Arguments in C# [duplicate]
问题 This question already has answers here : Closed 10 years ago . Duplicate Question Passing null arguments to C# methods Can I do this in c# for .Net 2.0? public void myMethod(string astring, int? anint) { //some code in which I may have an int to work with //or I may not... } If not, is there something similar I can do? 回答1: Yes, assuming you added the chevrons deliberately and you really meant: public void myMethod(string astring, int? anint) anint will now have a HasValue property. 回答2: