Click here to Skip to main content
Click here to Skip to main content
Alternative Tip

Tagged as

Go to top

TIP: Handling WPF DialogResult with simplicity

, 28 Jun 2010
Rate this:
Please Sign up or sign in to vote.
May be this is better?if (f.ShowDialog() ?? false) { // ebat' melkosoft za takie prikoly}
May be this is better?
 
if (f.ShowDialog() ?? false) {
   // ebat' melkosoft za takie prikoly
}

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Thornik

South Africa South Africa
No Biography provided

Comments and Discussions

 
GeneralRe: I like both: frm.ShowDialog(); if (frm.DialogResul... Pinmembervotecoffee29-May-11 23:44 
GeneralReason for my vote of 5 It's very simple and readable. Is th... Pinmemberosam12-Jul-11 7:28 
GeneralReason for my vote of 3 Not as readable. Pinmembervotecoffee29-May-11 7:47 
GeneralProgramming isn't just about having the shortest code or eve... Pinmembervotecoffee29-May-11 7:46 
Programming isn't just about having the shortest code or even the fastest code. Someone has to maintain it after you are gone. Readability trumps shortening or even speeding up code. Wherever possible, it should be written so that anyone can come behind you and understand the logic behind the code with just a glance.
GeneralRe: And?... Which alternative you prefer and why? PinmemberMember 308248729-May-11 22:58 
GeneralYep, your two lines example is definitely shorter than my in... PinmemberMember 30824877-Sep-10 23:13 
GeneralWhat looks shorter and understandable is: if (f.DialogResult... PinmemberJaime Olivares5-Sep-10 22:18 
GeneralOh, OK, "if (frm.DialogResult.HasValue && frm.DialogResult.V... PinmemberMember 308248720-Jul-10 0:23 
GeneralI really like so much the ?? operator, but in this case does... PinmemberJaime Olivares28-Jun-10 20:44 

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

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

| Advertise | Privacy | Mobile
Web02 | 2.8.140916.1 | Last Updated 28 Jun 2010
Article Copyright 2010 by Thornik
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid