Created
December 17, 2010 16:17
-
-
Save armsteadj1/745193 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For you, what's the ideal conditional structure in this situation? | |
// Notes: | |
// Assume user.Job.Title comes from an outside system that we cannot control the format of (thus requiring the Trim) | |
binding.Name = showAliasName ? (user.AliasName != null && user.Job.Title != null && user.Job.Title.Trim().Length > 0 ? user.AliasName + " " + user.Job.Title : "N/A") : (user.Name != null && user.Job.Title != null && user.Job.Title.Trim().Length > 0 ? user.Name + " " + user.Job.Title : user.Name); | |
// Or | |
binding.Name = showAliasName | |
? (user.AliasName != null && user.Job.Title != null && user.Job.Title.Trim().Length > 0 | |
? user.AliasName + " " + user.Job.Title | |
: "N/A") | |
: (user.Name != null && user.Job.Title != null && user.Job.Title.Trim().Length > 0 | |
? user.Name + " " + user.Job.Title | |
: user.Name); | |
// Or | |
if (showAliasName) | |
{ | |
if (user.AliasName != null && user.Job.Title != null && user.Job.Title.Trim().Length > 0) | |
{ | |
binding.Name = user.AliasName + " " + user.Job.Title; | |
} | |
else | |
{ | |
binding.Name = "N/A"; | |
} | |
} | |
else | |
{ | |
if (user.Name != null && user.Job.Title != null && user.Job.Title.Trim().Length > 0) | |
{ | |
binding.Name = user.Name + " " + user.Job.Title; | |
} | |
else | |
{ | |
binding.Name = user.Name; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment