This browser is no longer supported. Download Microsoft Edge More info. Contents Exit focus mode. Is this page helpful? Please rate your experience Yes No. Any additional feedback? Submit and view feedback for This product This page. View all page feedback. This is important for team environments with source code. It is not a contest to write code with the fewest characters.
It is a contest to write code with can be modified with the least disruption. This site uses Akismet to reduce spam. Learn how your comment data is processed. Search for: Search. Date: August 6, Author: dotnetguide4u 2 Comments. Name else set null. Name : null ;.
Name ;. WriteLine "Employee Details" ; Console. WriteLine "" ; Console. Age ; Console. WriteLine "Employee Address" ; Console. City ; Console. State ; Console. Country ; Console. Zip ; Console. WriteLine "Employee Details" ;. WriteLine "" ;. Age ;. WriteLine "Employee Address" ;. Improve this question. Paramone Paramone 1 1 gold badge 1 1 silver badge 7 7 bronze badges. This meas if it's not-null then it'll always be the highest value.
Both if s are completely unnecessary. I bet this is a part or a loop Add a comment. Active Oldest Votes. Improve this answer. If this happen then to be null is collo assuming it's a reference type and for that you have?. That said THIS is the right code, compiler does everything correctly not a surprise. Max highestWeightOfParcel, collo. Treat all variables as readonly, this dramatically simplifies code flow.
Single assignment is a golden rule especially if you do not force it chaining complex expressions and multiple ternary operators like in the other OP's example. It has however, other disadvantages often it's about readability and quick review of test coverage. Of course to introduce a function is even better. Just encapsulate complex assignment expressions.
But the one in this answer isn't complex enough to warrant this. This should be one expression, one line of code. Max enough? Is highestWeightOfParcel truly initialized with 0? Is it part of a more complex context which is or should be already in a separate function?
0コメント