Tuesday, June 2, 2015

Invoking a method without parentheses () in C#

The biggest difficult faced by any programmer coming to VB from C#, will the lack of parenthesis '()' when they want to call functions. In VB its not required to put ( ) to call functions. But we can put if we want. If we need to deal with legacy codebase which is developed by classic VB developers, we cannot expect any brackets in the functions calls.

It really reduces the readability of program. Each time when somebody see a word, they need to spend some time understanding whether its a function or property. Also to make sure what are the exact parameters, it will take some time. If we assume it will take 30 seconds for a developer to understand the intention of function call and its parameters without brackets, it will take considerable amount of time if we think about project with thousands of lines and 30-50 developers.

We (at least I am) are thinking that C# doesn't has this problem. But is that true? See the below code snippet.
Here the char.IsLower method is being invoked 3 times. But there is no parentheses used.

1 comment:

Blogger said...

If you need your ex-girlfriend or ex-boyfriend to come crawling back to you on their knees (even if they're dating somebody else now) you need to watch this video
right away...

(VIDEO) Why your ex will NEVER come back...