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

Simplify the initializing of fields and properties #872

Closed
qaqz111 opened this issue Sep 2, 2017 · 2 comments
Closed

Simplify the initializing of fields and properties #872

qaqz111 opened this issue Sep 2, 2017 · 2 comments

Comments

@qaqz111
Copy link

qaqz111 commented Sep 2, 2017

Since you can't use var to defined class members, you have to write this:

class A
{
    private Dictionary<string, Dictionary<string, List<(int count, string desc)>> infos =
        new Dictionary<string, Dictionary<string, List<(int count, string desc)>>(16);

    private List<int> list = new List<int>(16);
}

Yes VS can help completing the initialize statements after you input '=', but what if you want to change the type of the member? You have to modify it twice.

It will be simpler if there is a shorthanded way:

class A
{
    private Dictionary<string, Dictionary<string, List<(int count, string desc)>> infos = new(16);

    private List<int> list = new(16);
}
@qaqz111 qaqz111 changed the title Don't you think it is bothered initializing fields and properties? Simplify the initializing of fields and properties Sep 2, 2017
@svick
Copy link
Contributor

svick commented Sep 2, 2017

This looks like duplicate of #100.

@qaqz111
Copy link
Author

qaqz111 commented Sep 2, 2017

Yes I have not notice that.
Closed.

@qaqz111 qaqz111 closed this as completed Sep 2, 2017
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