[Proposal]: Allow default value for out parameter #3989
-
Allow default value for out parameter
SummaryAllow default value for MotivationDetailed designAllow add default value for bool Method(out string value) {
if(xxxx){
value = "xxx";
return true;
}
value = null;
return false;
} to bool Method(out string value = null) {
if(xxxx){
value = "xxx";
return true;
}
return false;
} This feature seems only need C# compiler level update by compiling parameter DrawbacksAlternativesUnresolved questionsDesign meetings |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 2 replies
-
What's the advantage of: bool Method(out string value = null) {
if(xxxx){
value = "xxx";
return true;
}
return false;
} over bool Method(out string value) {
value = null;
if(xxxx){
value = "xxx";
return true;
}
return false;
} |
Beta Was this translation helpful? Give feedback.
-
I'm going to convert this to a discussion. We generally want proposals to be more complete. Adding more around the motivation here would help sell the idea, as I agree with Yair that I don't see much of a benefit. |
Beta Was this translation helpful? Give feedback.
-
Duplicate of dotnet/roslyn#1757 resp. #1033 |
Beta Was this translation helpful? Give feedback.
Duplicate of dotnet/roslyn#1757 resp. #1033