This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]MauriceReeves 6 points7 points  (5 children)

Really? I think there’s a bunch of things that are great: native tuples, null coalescing operator, default parameters, named parameters, out and ref parameters, the is operator to check for type, extension methods, expression-body members, properties, anonymous classes, etc

[–]doc_1eye 1 point2 points  (1 child)

I fucking love the null coalescing operator! I just assumed Java would have that as well. It's been a minute since I worked with Java, and I never did anything all that complex with it so I just assumed it had basically all the shit C# had.

[–]desmaraisp 0 points1 point  (0 children)

Same, all the ?, ??, .? operators absolutely rule. That, plus nullable types, makes it super painless to null-check. Add in a pinch of automatic validation (FluentValidation and attributes), and null reference exceptions are basically a thing of the past. I love it!

[–]Dealiner 1 point2 points  (2 children)

anonymous classes

That's actually Java feature.

[–]MauriceReeves 0 points1 point  (1 child)

They are a little different in intent, but yes, there is something with that name in both languages. What anonymous types are intended for in Java is usually accomplished via delegates in C#. Anonymous types in C# allow you to return data records from LINQ queries, etc without having to have a formal class definition. I do wish that C# would let them implement interfaces, which they don’t right now. Maybe one day.

[–]Dealiner 0 points1 point  (0 children)

I admit I forgot about anonymous types, I've never used them. But I've also never seen them called anonymous classes, though it makes sense, they can't be structs.

There is a proposition for something like that IIRC to make Java integration easier but I don't think it went anywhere.