Click here to Skip to main content
15,900,378 members

Welcome to the Lounge

   

For discussing anything related to a software developer's life but is not for programming questions. Got a programming question?

The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.

 
GeneralRe: Ever use this syntax in C# 7? Pin
jschell16-Sep-17 7:02
jschell16-Sep-17 7:02 
GeneralRe: Ever use this syntax in C# 7? Pin
Slacker00715-Sep-17 6:04
professionalSlacker00715-Sep-17 6:04 
GeneralRe: Ever use this syntax in C# 7? Pin
  Forogar  15-Sep-17 7:54
professional  Forogar  15-Sep-17 7:54 
GeneralRe: Ever use this syntax in C# 7? Pin
Slacker00715-Sep-17 8:08
professionalSlacker00715-Sep-17 8:08 
GeneralRe: Ever use this syntax in C# 7? Pin
W Balboos, GHB15-Sep-17 6:36
W Balboos, GHB15-Sep-17 6:36 
GeneralRe: Ever use this syntax in C# 7? Pin
Dave Kreskowiak15-Sep-17 4:23
mveDave Kreskowiak15-Sep-17 4:23 
GeneralRe: Ever use this syntax in C# 7? Pin
TheGreatAndPowerfulOz15-Sep-17 5:19
TheGreatAndPowerfulOz15-Sep-17 5:19 
GeneralRe: Ever use this syntax in C# 7? Pin
Richard Deeming15-Sep-17 5:29
mveRichard Deeming15-Sep-17 5:29 
As far as I can tell, throw expressions only exist to make expression-bodied members work. Without them, you'd have to check for null and throw an ArgumentNullException, which would mean multiple lines, and therefore prevent you from using an expression body.

I'm sure some people will find a use for them. But I still much prefer using multi-statement bodies when there are multiple statements to execute.

And I'm not really a fan of using expression-bodied methods for properties with more than one accessor either.
C#
public string Name
{
    get => name;
    set => name = value ?? throw new ArgumentNullException(nameof(value));
}

// vs:

public string Name
{
    get => name;
    set
    {
        if (value == null) throw new ArgumentNullException(nameof(value));
        name = value;
    }
}

// vs:

public string Name
{
    get 
    {
        return name;
    }
    set
    {
        if (value == null) throw new ArgumentNullException(nameof(value));
        name = value;
    }
}




"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer


GeneralRe: Ever use this syntax in C# 7? Pin
Jon McKee15-Sep-17 6:49
professionalJon McKee15-Sep-17 6:49 
GeneralRe: Ever use this syntax in C# 7? Pin
Dave Kreskowiak15-Sep-17 7:28
mveDave Kreskowiak15-Sep-17 7:28 
GeneralRe: Ever use this syntax in C# 7? Pin
R. Giskard Reventlov15-Sep-17 4:50
R. Giskard Reventlov15-Sep-17 4:50 
GeneralRe: Ever use this syntax in C# 7? Pin
lopatir15-Sep-17 6:14
lopatir15-Sep-17 6:14 
GeneralRe: Ever use this syntax in C# 7? Pin
Jon McKee15-Sep-17 6:36
professionalJon McKee15-Sep-17 6:36 
GeneralRe: Ever use this syntax in C# 7? Pin
Munchies_Matt15-Sep-17 8:33
Munchies_Matt15-Sep-17 8:33 
GeneralLegal logic PinPopular
The pompey15-Sep-17 3:33
The pompey15-Sep-17 3:33 
GeneralRe: Legal logic Pin
Marc Clifton15-Sep-17 3:35
mvaMarc Clifton15-Sep-17 3:35 
GeneralRe: Legal logic Pin
Ron Anders15-Sep-17 3:38
Ron Anders15-Sep-17 3:38 
GeneralRe: Legal logic Pin
Eddy Vluggen15-Sep-17 3:38
professionalEddy Vluggen15-Sep-17 3:38 
GeneralRe: Legal logic Pin
megaadam15-Sep-17 3:41
professionalmegaadam15-Sep-17 3:41 
GeneralRe: Legal logic Pin
Eddy Vluggen15-Sep-17 3:43
professionalEddy Vluggen15-Sep-17 3:43 
GeneralRe: Legal logic Pin
The pompey15-Sep-17 3:51
The pompey15-Sep-17 3:51 
GeneralRe: Legal logic Pin
KarstenK15-Sep-17 4:46
mveKarstenK15-Sep-17 4:46 
GeneralRe: Legal logic Pin
Rick York15-Sep-17 5:19
mveRick York15-Sep-17 5:19 
GeneralRe: Legal logic Pin
Tim Carmichael15-Sep-17 3:43
Tim Carmichael15-Sep-17 3:43 
GeneralRe: Legal logic Pin
The pompey15-Sep-17 3:52
The pompey15-Sep-17 3:52 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.


Straw Poll

Were you affected by the geomagnetic storms this past weekend?
Communication disruptions, electrified pipes, random unexplained blue-screens in Windows - the list of effects is terrifying.
  Results   487 votes