Nothing not to love -- a whole bunch of syntax sugar that makes code cleaner without messing around with core concepts that breaks code conceptually. It's also great to see how quickly good ideas permeate the language landscape today versus ten years ago (or maybe it's just good ideas finally permeating the landscape all at once).
What's New in C# 6.0 [video]
91–100 of 145 posts
Re: What's New in C# 6.0 [video]
#92Re: What's New in C# 6.0 [video]
#93Earlier quoted context omitted.
And also for INotifyPropertyChanged! (Although CallerMemberName helped that some in C#5.)
I really really want property change notifications on auto-properties. Having to compare the incoming value against an explicit backing field is the cause of most of my boilerplate code when using WPF.
But my feeling is that it was kind of hopeless to do in C#: it is just so different from the language semantics. Something like FRP (real FRP, not Rx) or managed time [1] works much better, IMHO, but requires drastic language changes.
JavaFX Script (F3) also included data binding straight into the language, and is probably an idea of how to do it for C#.
[1] http://research.microsoft.com/en-us/people/smcdirm/managedti...
Re: What's New in C# 6.0 [video]
#94Re: What's New in C# 6.0 [video]
#95Using static classes as namespaces addresses something I was just complaining about a week ago. Let's take it a step further! Just let us put bare functions in namespaces without the dance of the static class.
F# module == C# static class. What is the problem?
Re: What's New in C# 6.0 [video]
#96Earlier quoted context omitted.
public int X { get; } is more consistent with how properties are declared. Consistency is important. If you care about clean code, here's an even better way public readonly int X; They are not exactly the same but they are equivalent in most cases. In exotic cases where you're required to use auto-getters, adding the brackets wouldn't hurt.
> public int X { get; } is more consistent with how properties are declared. Consistency is important. As mentioned in my other reply. If that were the case, why have they just changed the method declaration syntax? It's inconsistent and therefore unacceptable right? If everything has to be consistent we wouldn't have LINQ, lambdas, generics, etc. The braces are for scope in C# and all C derivative languages. There i…
They did change the property declaration syntax too.
public int X => 5;
is the same as public int X { get { return 5; } }
This is exactly the same change they made to the method declaration syntax, so I'm not sure what you're complaining about.Of course it isn't identical to public int X { get; } because the latter is assignable in the constructor. But comparing _that_ to methods is apples to oranges since methods aren't assignable.
Re: What's New in C# 6.0 [video]
#97Earlier quoted context omitted.
It is consistent with how other .Net libraries work (particularly the string ones). It also works fine on null as long as the type of null is string.
It works because it's an extension method, but aren't extension methods supposed to make things nice and consistent by making it look as if you're calling an instance method? Since this would be completely broken if it were an instance method, the reader might be surprised at first until they realize it's an extension method. So all I'm saying is that it's no less "counter-intuitive" than the normal string.IsNullOrWh…
Re: What's New in C# 6.0 [video]
#98Earlier quoted context omitted.
What is this called? It's impossible to google for
Informally the "Elvis operator".
Re: What's New in C# 6.0 [video]
#99Nothing not to love -- a whole bunch of syntax sugar that makes code cleaner without messing around with core concepts that breaks code conceptually. It's also great to see how quickly good ideas permeate the language landscape today versus ten years ago (or maybe it's just good ideas finally permeating the landscape all at once).
Re: What's New in C# 6.0 [video]
#100I'm a tiny bit disappointed with the inclusion of exception filters, but I suppose it is pragmatic feature. I'm fond of a pattern where error codes can be implicitly converted to Exceptions[1]. It's often argued that exceptions are for things that your program cannot handle and error codes are for things that it can. But, in my experience, whether or not a bad condition is an error or an exception depends upon the la…
I've never seen the arguments for error codes vs exception. Care to explain briefly or link me some information?