Instance .Method() ?

  • Thread starter Thread starter Brian
  • Start date Start date
B

Brian

I was studying someone else's code and came across something like this:

myX .Blah();

And it puzzled me because I didn't think it'd compile. It did.

I'm sure I haven't stumbled onto something new. C# doesn't care about
white space inbetween an instance variable and a method? Is this a
bonefide part of the spec or just a feature of Studio 2003?

Thanks.
 
The C# specification allows whitespace between any tokens. What you see is
allowed in the design of the language. In fact, it could even have read:

myX
.Blah()

with the elements on different lines. And it could also have been

myX.
Blah()

so the dot can be on either line.

HTH

DalePres
 
Back
Top