Re: << and >> operators in c#
- From: "Steve Richter" <StephenRichter@xxxxxxxxx>
- Date: 21 Jan 2007 19:48:53 -0800
Stephany Young wrote:
Maybe you would like to expand on the 'piping and 'adding' bits.
arrayOfLines << new string( "another line" ) ; // adds to the end
of the array
databaseTable << row ; // adds a row to the database table
the general rule being:
<< adds to something
= replaces the contents of something with something else.
Also, what makes you think that bit-shifting is seldom used?
I have not used bit shifting for years. If you are looking to multiply
or divide, better to use those operators. ( and the optimized compilers
of today likely bit shift when we multiply by a constant that is a
power of 2. )
-Steve
"Steve Richter" <StephenRichter@xxxxxxxxx> wrote in message
news:1169429467.473348.39610@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Ben wrote:
Hi,
I'm trying to figure out the purpose of these operators.
Now, I know what they do. They shift bits either left or right.
But I don't know why would anybody want to do that. I've never seen
anyone using it in his/her code.
Any ideas?
it is a tragic mistake that an operator that is tailor made for piping
and adding to lists, is reserved instead for such a trivial, seldom
used operation. If you want to shift bits, better to have a new literal
operator:
bunchOfBits shiftleft 2 ;
-Steve
.
- Follow-Ups:
- Re: << and >> operators in c#
- From: Christof Nordiek
- Re: << and >> operators in c#
- From: Stephany Young
- Re: << and >> operators in c#
- References:
- Re: << and >> operators in c#
- From: Steve Richter
- Re: << and >> operators in c#
- From: Stephany Young
- Re: << and >> operators in c#
- Prev by Date: RE: Creating ActiveX controls to be used by VB 6.0 programs
- Next by Date: Re: Should the Dispose( ) method only run when there are no other references to an object?
- Previous by thread: Re: << and >> operators in c#
- Next by thread: Re: << and >> operators in c#
- Index(es):
Relevant Pages
|