Converting 'foo = foo.Trim()' over to 'foo .= Trim()' or something to that effect #4245
Replies: 2 comments 1 reply
-
I proposed this way back in the roslyn repo: dotnet/roslyn#9134
Originally posted by @HaloFour in dotnet/roslyn#9134 (comment) It seems that there is not really a need for this kind of operator/syntactic sugar. I have to say, that I do quite agree when looking back. |
Beta Was this translation helpful? Give feedback.
-
This exact idea - plus alternatives syntax ideas - has been discussed before, and has always floundered on the question of value. Any proposal that has the sole benefit of making C# more concise has to address an extremely common case to be worth the cost of implementation. This is why changes like expression based methods were implemented while a slew of equally simple but less commonly applicable proposals have been passed over. In my experience, reassigning an existing variable to the result of calling a method on that exact instance is not only rare, but often a source of bugs as well. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Oftentimes we find ourselves trimming strings and what have you so I thought maybe it would make sense to support
foo .= Trim();
Feel free to suggest a more elegant syntax (but you get the idea). What does the community think?
Beta Was this translation helpful? Give feedback.
All reactions