I've always done it using option #1 - never really gave it much
thought, but it does bring up a good point - I do tend to use
parentheses in situations with multiple booleans when they're not
necessarily required, to make things easier to read.

In this case, I'd defend #1 by saying that the value being assigned is
always whatever is at the far right - in this case, ReadCString(),
regardless of what it's reading - If you want to know what you're
reading from, you'd read backwards (right to left), in which case the
parentheses don't really make it any clearer.

I guess my opinion is that it depends on your situation - in this
case, I'd skip the parenthesis, but if I was doing this in a big chain
of logic, maybe use them at that time...

On Jan 5, 12:48 pm, Glenn <[email protected]> wrote:
> Here's where you guys can voice your opinions...but at least back them up!
>
> I have a couple simple classes to input and output a string in the same
> format as MFC.  (Have to do it to be backward compatible with the existing
> MFC application.)  The base layout for the class is as follows:
>
> public class MFCStringReader : BinaryReader
> {
>   public MFCStringReader(Stream s) : base(s) {}
>
>   public String ReadCString()
>   {
>     <processing code here>
>   }
>
> There are many instances in which I only need to read one string.  How would
> you write it?
>
>   value = new MFCStringReader(sr).ReadCString();
>
> or
>
>   value = (new MFCStringReader(sr)).ReadCString();
>
> The first is a bit cleaner, but the second makes it clearer as to what is
> being returned.  Comments!
>
> ...Glenn

Reply via email to