using arraylist

  • Thread starter Thread starter wanwan
  • Start date Start date
So what you're saying is the "as operator" is like the TryCast command in
VB? If it can't cast it, it returns (null in C#, nothing in VB) ?

Robin S.
-------------------------
Göran Andersson said:
As you are unable to read the documentation yourself, I will explain it
to you.

The DirectCast will attempt to make a cast, and throw an exception if it
fails.

The as operator will attempt to make a cast, and returns null it it
fails.

Do you now see the difference, or is there still something that is
unclear to you?
 
Exactly.
So what you're saying is the "as operator" is like the TryCast command in
VB? If it can't cast it, it returns (null in C#, nothing in VB) ?

Robin S.
 
Ok, if you don't understand at all, I can try to make it really really
simple.

Think of the "DirectCast" function and the "as" operator as two bread
recognition machines. You put some bread in the machine, select the type
of bread you want, and the machine recignises if the bread in the
machine is the type of bread that you want.

Put some french bread in the "as" bread recognition machine, and press
the "american bread" button on the front. The machine will hum for a
while, then go beep. You open the machine and see that the bread is gone.

Put some french bread in the "DirectCast" bread recognition machine, and
press the "american bread" button on the front. The machine will hum for
a while, then it will explode.

Now do you see the difference?

Goran,

No I don't see the difference, you are telling in my opinion the same as the
difference between a French bread and an American bread. When I have
consumed it, it is completely the same.

Cor
 
Robin,

Where was I writing about the trycast, in my opinion is what it does more
important.

http://msdn2.microsoft.com/en-us/library/7k6y2h6x.aspx

However feel free to have another opinion.
I show this MSDN page here to let people who search on Google no other idea.

Cor

RobinS said:
So what you're saying is the "as operator" is like the TryCast command in
VB? If it can't cast it, it returns (null in C#, nothing in VB) ?

Robin S.
 
Who wants bread recognition machines from which you have to tell what kind
of bread you put in it.

However maybe is the problem that you are not familiar with Option Strict
On.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vblr7/html/vastmOptionStrict.asp

Cor




Göran Andersson said:
Ok, if you don't understand at all, I can try to make it really really
simple.

Think of the "DirectCast" function and the "as" operator as two bread
recognition machines. You put some bread in the machine, select the type
of bread you want, and the machine recignises if the bread in the machine
is the type of bread that you want.

Put some french bread in the "as" bread recognition machine, and press the
"american bread" button on the front. The machine will hum for a while,
then go beep. You open the machine and see that the bread is gone.

Put some french bread in the "DirectCast" bread recognition machine, and
press the "american bread" button on the front. The machine will hum for a
while, then it will explode.

Now do you see the difference?
 
Cor,

I never said *you* were writing about the trycast. I was responding to
Goran and what he said about the C# code using the "as" operator, and
trying to figure out what he was talking about in correlation to VB.

Robin S.
--------------------------------

Cor Ligthert said:
Robin,

Where was I writing about the trycast, in my opinion is what it does more
important.

http://msdn2.microsoft.com/en-us/library/7k6y2h6x.aspx

However feel free to have another opinion.
I show this MSDN page here to let people who search on Google no other
idea.

Cor
 
Robin,

I know,

Cor

RobinS said:
Cor,

I never said *you* were writing about the trycast. I was responding to
Goran and what he said about the C# code using the "as" operator, and
trying to figure out what he was talking about in correlation to VB.

Robin S.
 
The bread recognition machine is just a device to demonstrate a point to
a fool. It doesn't exist in the real world.

Are you really that stupid, or are you just pretending?
Who wants bread recognition machines from which you have to tell what kind
of bread you put in it.

However maybe is the problem that you are not familiar with Option Strict
On.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vblr7/html/vastmOptionStrict.asp

Cor




Göran Andersson said:
Ok, if you don't understand at all, I can try to make it really really
simple.

Think of the "DirectCast" function and the "as" operator as two bread
recognition machines. You put some bread in the machine, select the type
of bread you want, and the machine recignises if the bread in the machine
is the type of bread that you want.

Put some french bread in the "as" bread recognition machine, and press the
"american bread" button on the front. The machine will hum for a while,
then go beep. You open the machine and see that the bread is gone.

Put some french bread in the "DirectCast" bread recognition machine, and
press the "american bread" button on the front. The machine will hum for a
while, then it will explode.

Now do you see the difference?
 
Back
Top