Elegant one-line way to use TryParse

I don't know how about you, but for me using int.TryParse() always feel somehow not right, resulting in an ugly three lines of code to do just one operation: int value; if (!int.TryParse(valueToParseFromString, out value) value = 0; If you are looking for cleaner code to satisfy your inner pedant you can use this one-line solution instead: int value = int.TryParse(valueToParseFromString, out value) ? value : 0; It will parse the valueToParseFromString and on success assign it to the value variable, otherwise it will return 0.

Read More

How would I learn to code if I could start once again

A few days ago my friend asked me a question how would I learn web development if I could start once again with my current experience and what I would do differently which inspired me to write this post. After a few years of experience as a .NET developer, I have plenty of reflections about that and I hope some of them would be a good starting point for beginners. In this article, I will assume that you want to focus on back-end development of web applications and object oriented programming. Pick only one technology and start with a good book…

Read More