What’s New in C# 7.0

  • (2 Pages)
  • +
  • 1
  • 2

27 Replies - 2587 Views - Last Post: 28 April 2017 - 09:52 AM

#16 andrewsw  Icon User is offline

  • lashings of ginger beer
  • member icon

Reputation: 6340
  • View blog
  • Posts: 25,565
  • Joined: 12-December 12

Re: What’s New in C# 7.0

Posted 09 September 2016 - 06:20 AM

Eek. Are we creating a new language?
Was This Post Helpful? 0
  • +
  • -

#17 Skydiver  Icon User is offline

  • Code herder
  • member icon

Reputation: 5825
  • View blog
  • Posts: 19,844
  • Joined: 05-May 12

Re: What’s New in C# 7.0

Posted 09 September 2016 - 06:49 AM

Yes. Eek indeed. I completely agree.

I can foresee many style guides recommending either completely eschewing the use of this, or if it used that strict horizontal and vertical alignment be used so that readers can quickly identify what parts are the same and what parts are different when going from line to line.
Was This Post Helpful? 0
  • +
  • -

#18 tlhIn`toq  Icon User is offline

  • Xamarin Cert. Dev.
  • member icon

Reputation: 6505
  • View blog
  • Posts: 14,359
  • Joined: 02-June 10

Re: What’s New in C# 7.0

Posted 09 September 2016 - 07:07 AM

Huh? What does that example have to do with the display? Did I miss something? That example was just about the data model. That never has anything to do with the presentation. Its just data.
Was This Post Helpful? 0
  • +
  • -

#19 Curtis Rutland  Icon User is offline

  • (╯°□°)╯︵ (~ .o.)~
  • member icon


Reputation: 5101
  • View blog
  • Posts: 9,283
  • Joined: 08-June 10

Re: What’s New in C# 7.0

Posted 09 September 2016 - 07:59 AM

I personally like expression body functions, and will welcome expression body constructors and accessors. Now if I can just get the people I work with to update to C# 6...seriously, it's been out long enough. I still have to sometimes go through my code and remove template strings and expression body functions before they can compile it.
Was This Post Helpful? 0
  • +
  • -

#20 Skydiver  Icon User is offline

  • Code herder
  • member icon

Reputation: 5825
  • View blog
  • Posts: 19,844
  • Joined: 05-May 12

Re: What’s New in C# 7.0

Posted 09 September 2016 - 09:08 AM

View PosttlhIn`toq, on 09 September 2016 - 10:07 AM, said:

Huh? What does that example have to do with the display? Did I miss something? That example was just about the data model. That never has anything to do with the presentation. Its just data.


I was talking about coding style guides.

Compare:
class Foo : IEquatable<Foo>
{
    public int Bar { get; }
    public int Fizz => Bar * 5;
    public int FizzBin { get => 2 * Bar; set => value / 2; }
    public int Fuzz => Bar * 3;
    public double Baz { get => Math.Sqrt(Bar); }
    public string Fuzzy => $"{Fizz}{Fuzzy}";
    public Foo(int bar) => Bar = bar;
    public string override ToString() => $"{FizzBin}";
    public int Square() => Bar * Bar;
    public bool Equals(Foo foo) => foo.Bar == Bar;
    public bool override Equals(object obj) => Equals((Foo) obj);
}



vs.
class Foo : IEquatable<Foo>
{
    public int    Bar      { get; }

    public int    Fizz  => Bar * 5;
    public int    Fuzz  => Bar * 3;
    public string Fuzzy => $"{Fizz}{Fuzzy}";
    public double Baz
    {
                  get   => Math.Sqrt(Bar);
    }
    public int    FizzBin
    {
                  get   => 2 * Bar;
                  set   => value / 2;
    }

    public        Foo(int bar)      => Bar = bar;
    public int    Square()          => Bar * Bar;
    public bool   Equals(Foo other) => other.Bar == Bar;

    public string override ToString()         => $"{FizzBin}";
    public bool   override Equals(object obj) => Equals((Foo) obj);
}


Was This Post Helpful? 0
  • +
  • -

#21 Ratatoskr  Icon User is offline

  • D.I.C Head

Reputation: 40
  • View blog
  • Posts: 223
  • Joined: 02-January 16

Re: What’s New in C# 7.0

Posted 14 March 2017 - 10:54 PM

I like the tuples and deconstruction. However, should I be cautious of using these liberally? Would it be wrong for me to prefer using a tuples over a string array, in some situations, for example?

I also like the out variables.
Was This Post Helpful? 0
  • +
  • -

#22 JapanDave  Icon User is online

  • D.I.C Regular

Reputation: 29
  • View blog
  • Posts: 363
  • Joined: 01-February 16

Re: What’s New in C# 7.0

Posted 27 April 2017 - 04:42 AM

So how do we get this new stuff? I can't find an upgrade for C# 7.0????
Was This Post Helpful? 0
  • +
  • -

#23 Curtis Rutland  Icon User is offline

  • (╯°□°)╯︵ (~ .o.)~
  • member icon


Reputation: 5101
  • View blog
  • Posts: 9,283
  • Joined: 08-June 10

Re: What’s New in C# 7.0

Posted 27 April 2017 - 07:47 AM

You can compile C# 7 code just by adding the following Nuget package: Microsoft.Net.Compilers. If you're still in VS 2015 or lower, you'll see syntax errors in the IDE but the code will compile correctly. Using VS 2017 you will not see the errors. There are some other packages you have to install for features, like System.ValueTuple for native tuples to work.
Was This Post Helpful? 0
  • +
  • -

#24 JapanDave  Icon User is online

  • D.I.C Regular

Reputation: 29
  • View blog
  • Posts: 363
  • Joined: 01-February 16

Re: What’s New in C# 7.0

Posted 27 April 2017 - 06:44 PM

Thanks Curtis. Is VS 2017 stable enough to use?
Was This Post Helpful? 0
  • +
  • -

#25 Skydiver  Icon User is offline

  • Code herder
  • member icon

Reputation: 5825
  • View blog
  • Posts: 19,844
  • Joined: 05-May 12

Re: What’s New in C# 7.0

Posted 27 April 2017 - 06:54 PM

The RTM version has been very solid for me, but I've read/heard of issues people have had with the various betas and release candidates.
Was This Post Helpful? 0
  • +
  • -

#26 baavgai  Icon User is offline

  • Dreaming Coder
  • member icon


Reputation: 6966
  • View blog
  • Posts: 14,572
  • Joined: 16-October 07

Re: What’s New in C# 7.0

Posted 28 April 2017 - 05:15 AM

View PostJapanDave, on 27 April 2017 - 08:44 PM, said:

Is VS 2017 stable enough to use?


Been using it since we could download it, via work's MS contract. So about a month? I haven't truly tortured it yet, but all seems well. Say what you will of Microsoft, the core of Visual Studio has always been solid.

The extensions can go off the rails, though. The experimental npm .json project files was crap when I first looked at it, though they're getting better. Actually, they kind of seem to be moving npm stuff to Visual Code and catering to the cross platform webby crowd there.
Was This Post Helpful? 0
  • +
  • -

#27 Curtis Rutland  Icon User is offline

  • (╯°□°)╯︵ (~ .o.)~
  • member icon


Reputation: 5101
  • View blog
  • Posts: 9,283
  • Joined: 08-June 10

Re: What’s New in C# 7.0

Posted 28 April 2017 - 07:15 AM

@baavgai, speaking of VS Code, it's rapidly becoming my favorite tool in my kit. I've been doing a ton of web dev lately, and I've got to say that VS Code has been a joy to work in, compared to how mediocre VS is for web languages like JS/TS/HTML.

That aside, I've also been using 2017 since it was available and I haven't run into any issues with it. I don't really use any extensions though; was a R# guy, but VS 2017 doesn't really seem to need it.
Was This Post Helpful? 0
  • +
  • -

#28 baavgai  Icon User is offline

  • Dreaming Coder
  • member icon


Reputation: 6966
  • View blog
  • Posts: 14,572
  • Joined: 16-October 07

Re: What’s New in C# 7.0

Posted 28 April 2017 - 09:52 AM

@Curtis Rutland: Curiously, one of the reasons I was keen on playing with VS 2017 was to see if it had gotten better at JS/TS dev. Alas, there's significant improvement that I can see.

VS Code, on the other hand, continues to improve and is my tool of choice for many things. Honestly, the intellisense for TypeScript / Javascript makes VS look bad.

I found I missed F#'s Seq and mostly implemented it in TypeScript. I never got around to the docs; I was rather annoyed a decent generator didn't exist. You can check it out here if you're curious: https://github.com/Baavgai/seqnext I left the .vscode stub in on purpose. Can be installed from npm. Basically, ES6 iterators look like convoluted overkill to me.
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2