Click here to Skip to main content
15,886,362 members

Survey Results

For the C# devs: expression body or old school functions?

Survey period: 21 Feb 2022 to 28 Feb 2022

Do you prefer the expression body public override string ToString() => "I am an object"; or the traditional public override string ToString() { return "I am a string"; }?

OptionVotes% 
I prefer the shortened expression body syntax13717.13
I prefer traditional functions31639.50
It depends on the situation18122.63
I don't care8911.13
I'd never heard of expression body definitions779.63



 
GeneralRe: I have so few one-line methods... Pin
Wendelius22-Feb-22 8:35
mentorWendelius22-Feb-22 8:35 
GeneralSwift is topping that easy Pin
KarstenK20-Feb-22 21:30
mveKarstenK20-Feb-22 21:30 
GeneralRe: Swift is topping that easy Pin
musefan20-Feb-22 23:22
musefan20-Feb-22 23:22 
GeneralRe: Swift is topping that easy Pin
KarstenK21-Feb-22 1:55
mveKarstenK21-Feb-22 1:55 
GeneralRe: Swift is topping that easy Pin
musefan21-Feb-22 2:55
musefan21-Feb-22 2:55 
GeneralRe: Swift is topping that easy Pin
KarstenK21-Feb-22 3:26
mveKarstenK21-Feb-22 3:26 
GeneralWhat a load of Pin
den2k8820-Feb-22 20:50
professionalden2k8820-Feb-22 20:50 
GeneralRe: What a load of Pin
Sammuel Miranda21-Feb-22 8:14
professionalSammuel Miranda21-Feb-22 8:14 
Agreed. I do a lot of inline definitions, and even then, this change adds nothing... really,

This:
public override string ToString() { return "No, just ... NO!"; }

And this:
public override string ToString() => "No, just ... NO!";

It's just 8 characters shorter ... are everyone becoming so lazy, that typing begin and end of context/function is too much for then to cope with?
GeneralRe: What a load of Pin
Julian Ragan22-Feb-22 4:59
Julian Ragan22-Feb-22 4:59 
GeneralI prefer the shortened version, but it can be a pain. Pin
OriginalGriff20-Feb-22 19:14
mveOriginalGriff20-Feb-22 19:14 
GeneralRe: I prefer the shortened version, but it can be a pain. Pin
Slacker00721-Feb-22 0:37
professionalSlacker00721-Feb-22 0:37 
GeneralRe: I prefer the shortened version, but it can be a pain. Pin
Rob Grainger23-Feb-22 4:21
Rob Grainger23-Feb-22 4:21 

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.