runtime
runtime copied to clipboard
Question: Why C# doesn't allow passing parameter as final?
In Java, you can mark variable as final
public void GetById(final int id)
{
// Get by id and don't change id
}
Why this is not allowed in C#. There are many questions like this in Stackoverflow but I prefer to ask here to get the right reason behind that, not just theoretical answers.
This is a question/suggestion for the csharplang repo, not coreclr. I'm pretty sure they already have some discussions around allowing readonly to be used for local variables.
Ok, I will close it and move it there. Thanks,