Remove params arguments option #7843
Replies: 2 comments 2 replies
-
It's a breaking change, even if it's the best practice what we can do is just add a warning diagnostic |
Beta Was this translation helpful? Give feedback.
2 replies
-
This would break the world badly. If you would like to disallow |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I propose to remove the params arguments option from the c# language.
The c# language allows using the params keyword to enlist a set as tail arguments to an array:
public static void UseParams(params int[] list)
The problem with this feature is that it may lead to unclarities and programming errors. With the new array initializers, it would be fairly simple to write the list of arguments without using the params feature
UseParams(["a", 1])
instead ofUseParams("a", 1)
The params syntax is dangerous ambigue in cases like with EntitityFramework
db.Items.FindAsync(id, cancellationToken)
(wrong) instead ofdb.Items.FindAsync([id], cancellationToken)
(right)Beta Was this translation helpful? Give feedback.
All reactions