generic that wanted an initalizer function. was meant to be about "VS complains about adding the type in new()" buut I answered to the wrong comment, whoops
not even c#, visual studio or anyone wants you to do it this way or the other way
set up your .editorconfig as you like it and make warnings (or errors, if you prefer), style suggestions and refactoring suggestions to actually mean something
Actually those suggestions come from the Roslyn Analyzers made by the .NET team (the same things that provide intellisense). So you are in both technical and general senses correct in saying "that is what .NET wants".
are absolutely identical in terms of what they compile down to, so it's basically entirely down to personal preference / what coding standards you are abiding by.
Oh yeah, I don't disagree. Just saying for the sake of conversation, really.
But var record = new Record(); > Record record = new(); unless using class field or property then public Record Record { get; set; } = new(); or instatiate within a method is best imo.
If you mean parentheses (‘(‘ and ‘)’) then that’s usually calling a function or method with the name being the text right before it. A function or method is a way to call a bunch of lines of code in one line. They can have input(s) which would usually go inside of the parentheses, separated by commas if there is more than one, but if there are no input(s) to said method/function then the parentheses stay there anyways.
3.6k
u/a-slice-of-toast Aug 01 '22
creates a new record, obviously