You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
publicpartialclassExtensionMethodsRefPropertyParameter{publicintNumber{get;set;}=3;publicvoidWithExtensionMethod(){this.Number.NegEx();}publicvoidWithMethod(){intargnum= Number;
MathEx.Neg(ref argnum);Number=argnum;}}publicstaticpartialclassMathEx{publicstaticvoidNegEx(thisrefintnum){num=-num;}publicstaticvoidNeg(refintnum){num=-num;}}1 target compilation errors:
CS0206: A property or indexer may not be passed as an out or ref parameter
When applying extension methods with ref parameters to properties, they should be handled in the same way as ref parameters in regular methods.
VB.Net input code
Erroneous output
Expected output
Details
The text was updated successfully, but these errors were encountered: