instanceOf

  • Thread starter Thread starter rua17
  • Start date Start date
R

rua17

Can anyone tell me what's the command in c#
that is equivalent to the instanceOf in java?

thanks
 
Can anyone tell me what's the command in c#
that is equivalent to the instanceOf in java?

The 'is' operator

if ( obj is SomeType )



Mattias
 
Check GetType and TypeOf

x instanceOf y

will be

x.GetType()==y.GetType();
or
TypeOf(x)==TypeOf(y);

HTH
Alex
 
AlexS said:
Check GetType and TypeOf

x instanceOf y

will be

x.GetType()==y.GetType();
or
TypeOf(x)==TypeOf(y);

No it's not. For instance:

FileStream fs = new FileStream (...);

(fs instanceof Stream) should be true, but that won't work with the
above.

The equivalent C# operator to Java's "instanceof" operator is "is".
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top