Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a reason to return null inside parentheses

Tags:

c#

.net

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?

like image 914
nuclear sweet Avatar asked Nov 20 '25 03:11

nuclear sweet


2 Answers

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.

MSDN also has this

Many programmers use parentheses to enclose the expression argument of the return statement. However, C does not require the parentheses.

like image 82
TheNorthWes Avatar answered Nov 22 '25 18:11

TheNorthWes


There is no reason for that, you can just as easily type

return null;
like image 39
dotnetom Avatar answered Nov 22 '25 17:11

dotnetom



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!