What's the reason to use return value in parenthesis?

G

Guest

I've seen a lot of times using return value in parentesises -
{
....
return (true);
}

What's the reason for this? Can smb explait it?

PS: they do return predefined values, not calculated like returd (I*(d/4))
--
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/laflour

"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsche
 
J

Jon Skeet [C# MVP]

Michael said:
I've seen a lot of times using return value in parentesises -
{
...
return (true);
}

What's the reason for this? Can smb explait it?

PS: they do return predefined values, not calculated like returd (I*(d/4))

There's no technical reason. In some cases it can increase readability,
but that's pretty rare IMO.

Jon
 
I

Ignacio Machin \( .NET/ C# MVP \)

Hi,

Michael Nemtsev said:
I've seen a lot of times using return value in parentesises -
{
...
return (true);
}

What's the reason for this? Can smb explait it?

no reason at all, probably it's auto generated code, I frankly doubt
somebody owuld do it like that manually
 
J

James Curran

Basically, because it makes return look like a function. Note that in C
(and C++ and therefore C#), most constructs look like functions:
if(...)
while(...)
for(...)

One should note the in C/C++ there's no reason to wrap parens around the
operand of the sizeof operator -- still, most poeple do, because they think
of it as a function.
int l = sizeof long;
int i = sizeof(int);

This is noteworthy, because it C# cousin, typeof, *does* require parens,
even though there no more of a need for it then there is on sizeof or
return.
Type T = typeof(System.String);


--
Truth,
James Curran
[erstwhile VC++ MVP]

Home: www.noveltheory.com Work: www.njtheater.com
Blog: www.honestillusion.com Day Job: www.partsearch.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top