Click here to Skip to main content
15,890,506 members
Home / Discussions / C#
   

C#

 
GeneralRe: Regular Expressions Problem Pin
Richard MacCutchan28-Jun-13 3:30
mveRichard MacCutchan28-Jun-13 3:30 
QuestionWord Object Error Pin
bganesan27-Jun-13 22:18
bganesan27-Jun-13 22:18 
QuestionRe: Word Object Error Pin
ZurdoDev28-Jun-13 9:43
professionalZurdoDev28-Jun-13 9:43 
Questionhelp button and f1 key error Pin
User349027-Jun-13 22:09
User349027-Jun-13 22:09 
QuestionControling a scroll bar for Remote Desktop Pin
Andre O Rahming27-Jun-13 7:42
Andre O Rahming27-Jun-13 7:42 
QuestionC# desktop type ahead Pin
dcof27-Jun-13 6:35
dcof27-Jun-13 6:35 
AnswerRe: C# desktop type ahead Pin
Ron Beyer27-Jun-13 6:49
professionalRon Beyer27-Jun-13 6:49 
QuestionParanoid Question of the Day Pin
Keith Barrow27-Jun-13 3:50
professionalKeith Barrow27-Jun-13 3:50 
C#
public void Foo(Bar bar)
{
    if (bar== null)
    {
        bar = new Bar();
    }
    //Do something with bar;
}


--- or ---

C#
public void Foo(Bar bar)
{
    bar = bar ? new Bar();
    //Do something with bar;
}


Which do you think is better?

[Edit]
Thanks all for your help. I opted for 1 (it was the original code so I know it'll make it through the code review) and easier for newer devs to understand. I might drop the {}.
“Education is not the piling on of learning, information, data, facts, skills, or abilities - that's training or instruction - but is rather making visible what is hidden as a seed”
“One of the greatest problems of our time is that many are schooled but few are educated”


Sir Thomas More (1478 – 1535)


modified 28-Jun-13 9:22am.

AnswerRe: Paranoid Question of the Day Pin
PIEBALDconsult27-Jun-13 3:56
mvePIEBALDconsult27-Jun-13 3:56 
AnswerRe: Paranoid Question of the Day Pin
vonb27-Jun-13 4:03
vonb27-Jun-13 4:03 
GeneralRe: Paranoid Question of the Day Pin
Dave Kreskowiak27-Jun-13 8:06
mveDave Kreskowiak27-Jun-13 8:06 
AnswerRe: Paranoid Question of the Day Pin
Richard MacCutchan27-Jun-13 4:14
mveRichard MacCutchan27-Jun-13 4:14 
GeneralRe: Paranoid Question of the Day Pin
harold aptroot27-Jun-13 8:13
harold aptroot27-Jun-13 8:13 
GeneralRe: Paranoid Question of the Day Pin
Richard MacCutchan27-Jun-13 20:59
mveRichard MacCutchan27-Jun-13 20:59 
GeneralRe: Paranoid Question of the Day Pin
harold aptroot28-Jun-13 1:23
harold aptroot28-Jun-13 1:23 
GeneralRe: Paranoid Question of the Day Pin
Richard MacCutchan28-Jun-13 2:18
mveRichard MacCutchan28-Jun-13 2:18 
GeneralRe: Paranoid Question of the Day Pin
harold aptroot28-Jun-13 2:25
harold aptroot28-Jun-13 2:25 
GeneralRe: Paranoid Question of the Day Pin
Richard MacCutchan28-Jun-13 2:58
mveRichard MacCutchan28-Jun-13 2:58 
GeneralRe: Paranoid Question of the Day Pin
harold aptroot28-Jun-13 3:05
harold aptroot28-Jun-13 3:05 
GeneralRe: Paranoid Question of the Day Pin
Richard MacCutchan28-Jun-13 3:07
mveRichard MacCutchan28-Jun-13 3:07 
GeneralRe: Paranoid Question of the Day Pin
harold aptroot28-Jun-13 3:11
harold aptroot28-Jun-13 3:11 
GeneralRe: Paranoid Question of the Day Pin
Richard MacCutchan28-Jun-13 3:23
mveRichard MacCutchan28-Jun-13 3:23 
GeneralRe: Paranoid Question of the Day Pin
harold aptroot28-Jun-13 3:32
harold aptroot28-Jun-13 3:32 
GeneralRe: Paranoid Question of the Day Pin
Richard MacCutchan28-Jun-13 3:43
mveRichard MacCutchan28-Jun-13 3:43 
GeneralRe: Paranoid Question of the Day Pin
harold aptroot28-Jun-13 4:23
harold aptroot28-Jun-13 4:23 

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.