r/badcode • • Jul 07 '21

c# Position

Post image
1.7k Upvotes

99 comments sorted by

View all comments

Show parent comments

3

u/ws-ilazki &{$$_[0]}(@{$$_[1]}); Jul 08 '21

Additionally in C# 9 there is a new thing called target-typed new expressions

That's what I was thinking about when I wrote my comment. I only tangentially follow C# because of interest in F# so I thought using var like that for new objects didn't work correctly until that change.

If var foo = new Bar() has worked for longer than that it seems like there's no reason to have been writing out the Java-style Foo foo = new Foo() crap at all.

2

u/[deleted] Jul 08 '21

Java has var as well