Reputation: 1121
I found return(null)
in
http://msdn.microsoft.com/ru-ru/library/system.xml.serialization.ixmlserializable.aspx
I wonder is there some reason for this parentheses ? Why not just return null
?
Upvotes: 3
Views: 819
Reputation: 86506
In C#, the expressions foo
and (foo)
evaluate to exactly the same thing. The parens have no effect when the expression only has one term.
I actively prefer not using them, though, for a couple of reasons:
return(null)
resembles a function call just a little too closely. If you do use them, you should probably stick a space after the return
.
Upvotes: 0
Reputation: 2739
Hmm this was a curious question so I did some browsing.
I found this post which was posted answered by Jon Skeet. He states sometimes it increases readability but has no performance or logical impact.
Another user suggests it is a hold over from long ago when some compilers for C required them.
Interesting to see an example on MSDN with it though, nice find.
Many programmers use parentheses to enclose the expression argument of the return statement. However, C does not require the parentheses.
Upvotes: 4
Reputation: 24901
There is no reason for that, you can just as easily type
return null;
Upvotes: 3