This project is read-only.

Scope rules for field initializers for types with primary constructors

Topics: C# Language Design
Jul 17, 2014 at 9:03 AM
Consider following code
using System;

partial class PC
    Func<int, int> f = (arg) => 1;

partial class PC (int arg) 
This at the moment produces following error CS0136: A local or parameter named 'arg' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter

That's quite confusing and does not match behaviour when one writes constructor explicitly instead of using primary constructor.

Is this really the intended behaviour or a bug?