What’s new in C# 6.0

Monkey Archive Forums/Digital Discussion/What’s new in C# 6.0

Danilo(Posted 2016) [#1]
- What's new in C# 6.0

Would the 0-operator be something for MX2?

Now:
If obj <> Null
    obj.TheMethod()
EndIf

If obj <> Null Then obj.TheMethod()

Can be:
obj?.TheMethod()

I think that’s pretty useful.


ziggy(Posted 2016) [#2]
Yes I'm very used to it now so that I miss it a lot on Monkey


Beaker(Posted 2016) [#3]
I like that a lot. Null checking is one of the most pointlessly verbose structures.


marksibly(Posted 2016) [#4]
I like it too! Had a quick look through some compiler code and could see several places where it would work. Added to the roadmap...


tiresius(Posted 2016) [#5]
I've been doing this way ...
If obj Then obj.TheMethod()


... but I guess a shortcut would be cooler.


SLotman(Posted 2016) [#6]
Is it just me that sees that as another thing that will make code harder to read?


taumel(Posted 2016) [#7]
Quite some languages are trying to make things less cumbersome, implying concepts by the syntax, reducing prefixing work, offering a more cleaned up syntax, ... The more Mark can go into such a direction, the better. Having a small user base can be an advantage.