-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Please allow ref on foreach variable in case of an array #16155
Comments
This is genius. |
I assume that |
That seems extremely unlikely, given the team's resistance to making anything read-only by default. In fact, the only use-case I can think of for this would be: foreach(ref var item in array)
{
item = some new value;
} which would mean it would be useless if read-only. Unless I'm missing the obvious as usual... 😊 |
@jnm2 It is actually C++. :) @HaloFour Since this would be only allowed for arrays, it is totally safe to be assigned. I think that's the case for @DavidArno It is currently readonly for non-ref case, which is a good thing. But in this case we explicitly declared it as |
Except for |
In order to make that readonly we'd need to support the notion of |
@jaredpar You mean like the next major release? |
@eyalsk it will not be a part of C# 7.0. But it is a candidate for coming out in a point release / VS update. |
@jaredpar Thank you very much. |
Moved to dotnet/csharplang#461 |
->
The text was updated successfully, but these errors were encountered: