471,319 Members | 1,300 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,319 software developers and data experts.

Right shift operator

ERE
Pardon me if this has been asked a million times -- but I thought that
because of generics, the right shift operator was supposed to change with C#
2.0. I thought it was supposed to change from ">>" to "> >", to distiguish
it from nested generics.

But I've been using VS2005, and when I put in the new syntax I get an error
message, whereas the old syntax, as shown in the following code continues to
work fine. What am I missing?

Thanks,
Dan

------------------
static void Main( )
{
for (int i = 32; i > 0; )
{
i = i >> 1;
Console.WriteLine("Value: {0}", i);
}
}
Dec 18 '05 #1
3 2483
ERE <ea*******@ma.ultranet.com> wrote:
Pardon me if this has been asked a million times -- but I thought that
because of generics, the right shift operator was supposed to change with C#
2.0. I thought it was supposed to change from ">>" to "> >", to distiguish
it from nested generics.

But I've been using VS2005, and when I put in the new syntax I get an error
message, whereas the old syntax, as shown in the following code continues to
work fine. What am I missing?


The right shift operator itself hasn't been changed in terms of what
you write. It's been changed in terms of what one part of the compiler
gives to the other. Instead of the parser recognising one token of
">>" it recognises two tokens, each of which is ">".

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Dec 18 '05 #2
On Sat, 17 Dec 2005 23:33:57 -0800, "ERE" <ea*******@ma.ultranet.com>
wrote:
Pardon me if this has been asked a million times -- but I thought that
because of generics, the right shift operator was supposed to change with C#
2.0. I thought it was supposed to change from ">>" to "> >", to distiguish
it from nested generics.

But I've been using VS2005, and when I put in the new syntax I get an error
message, whereas the old syntax, as shown in the following code continues to
work fine. What am I missing?

Thanks,
Dan

------------------
static void Main( )
{
for (int i = 32; i > 0; )
{
i = i >> 1;
Console.WriteLine("Value: {0}", i);
}
}


There has been no change to what you type, right-shift is still ">>"
and right-shift assignment is still ">>=". There has been a change to
the underlying grammar to prevent the compiler treating the >> in
nested generics as if it was a right-shift. The change is only of
interest to compiler writers and does not affect the code that you
write.

HTH

rossum

--

The ultimate truth is that there is no ultimate truth
Dec 18 '05 #3
ERE
Thanks!

Dan

"Jon Skeet [C# MVP]" <sk***@pobox.com> wrote in message
news:MP************************@msnews.microsoft.c om...
ERE <ea*******@ma.ultranet.com> wrote:
Pardon me if this has been asked a million times -- but I thought that
because of generics, the right shift operator was supposed to change with
C#
2.0. I thought it was supposed to change from ">>" to "> >", to
distiguish
it from nested generics.

But I've been using VS2005, and when I put in the new syntax I get an
error
message, whereas the old syntax, as shown in the following code continues
to
work fine. What am I missing?


The right shift operator itself hasn't been changed in terms of what
you write. It's been changed in terms of what one part of the compiler
gives to the other. Instead of the parser recognising one token of
">>" it recognises two tokens, each of which is ">".

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too

Dec 20 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

12 posts views Thread by DeepaK K C | last post: by
43 posts views Thread by Mehta Shailendrakumar | last post: by
4 posts views Thread by Kevin | last post: by
reply views Thread by ERE | last post: by
16 posts views Thread by Santosh Nayak | last post: by
4 posts views Thread by G Iveco | last post: by
2 posts views Thread by gaya3 | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.