The text of this article is not in this database — only its details are. Read it on the old site: Var Keyword In C#
6 Comments
Join the conversation! Your thoughts help the community grow.
Sign in to leave a comment.
The text of this article is not in this database — only its details are. Read it on the old site: Var Keyword In C#
Join the conversation! Your thoughts help the community grow.
Sign in to leave a comment.
Thrainder KumarPosted Aug 31, 2021, 11:40 AM
If we try to assign a string value from string list into a var variable then how to handle if where condition on list doesn't return any value.
Rajanikant HawaldarPosted Feb 28, 2020, 2:57 AM
If you add comments for code that should be in English.
Hemalatha SunnapuPosted Nov 2, 2018, 2:32 AM
Why it is allowed in method scope...any sepecific reason...
Alan MPosted Aug 10, 2018, 9:04 AM
The use of the var keyword in anything larger than a update script or a data tool is bad practice. It is bad practice for a myriad of reasons, the most generally applicable are as follows. Anything that reduces the readability of code, or introduces ambiguity on ANY level is a problem waiting to happen. Code is hierarchical by nature, meaning clear design is imperative. If you use anything that makes it unclear you are going to have design issue that will be extremely difficult to isolate. I have seen this cost thousands of euro in a previous project. Secondly, if you actually cannot understand the type that is being returned from some function or query, the query needs to be refactored. Always fit the data structure to the existing code, rather than mashing the code into dealing with fields/members that were patched in in a 17:00 on a Friday commit. Finally, if you want the code standards of your project to be adhered to, keep vars,ternary operators and bizarre RegEX to a minimum. Frustration at ambiguity will most definitely breed further ambiguity, even among senior developers. I could go on, really I could, I have seen this so many times and seen its fallout so many times more. So, take it from me, write your code properly, or your project is going to fail. Computers are supposed to be easy to use.
Mahesh ChandPosted Apr 26, 2013, 7:19 AM
You should post code as code, not images.