Skip to content
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

Generated constructor should behave the same way as hand-written #3

Closed
hazzik opened this issue Aug 11, 2013 · 1 comment
Closed

Generated constructor should behave the same way as hand-written #3

hazzik opened this issue Aug 11, 2013 · 1 comment

Comments

@hazzik
Copy link

hazzik commented Aug 11, 2013

if I have fields with initializers they will not be called with generated constructor.

class X
{
    private int y = 42; // this will be called before base constructor.

    public X(int z) 
    {
    }
}

The generated code will be like following

class X
{
    private int;

    public X(int z) 
    {
       this.y = 42;
       base..ctor();
    }

    public X() : base () 
    {
        //y should be initialized here as well.
    }  
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants