473,320 Members | 1,814 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

instanceOf

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

thanks
Nov 15 '05 #1
5 61289
Check GetType and TypeOf

x instanceOf y

will be

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

HTH
Alex

"rua17" <ru***@hotmail.com> wrote in message
news:O8**************@TK2MSFTNGP09.phx.gbl...
Can anyone tell me what's the command in c#
that is equivalent to the instanceOf in java?

thanks

Nov 15 '05 #2
>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

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/
Please reply only to the newsgroup.
Nov 15 '05 #3
If you are coming from Java this may help:

http://www.geocities.com/jeff_louie/OOP/oop5.htm

Chapter 5 "C++ and Java Gumption Traps"*

Regards,
Jeff

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 15 '05 #4
AlexS <sa***********@SPAMsympaticoPLEASE.ca> wrote:
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".

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 15 '05 #5
thanks

"AlexS" <sa***********@SPAMsympaticoPLEASE.ca> wrote in message
news:uT**************@TK2MSFTNGP11.phx.gbl...
Check GetType and TypeOf

x instanceOf y

will be

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

HTH
Alex

"rua17" <ru***@hotmail.com> wrote in message
news:O8**************@TK2MSFTNGP09.phx.gbl...
Can anyone tell me what's the command in c#
that is equivalent to the instanceOf in java?

thanks


Nov 15 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: John MacIntyre | last post by:
Hi, I have a page with a series of child pages loaded into an iframe. When I move from page to page, I store an object containing the child's control data in a variable on the main page, then...
7
by: chirs | last post by:
Hi, These 2 lines caused an error in IE5. The error is "Function expected". Why? var d=new Date(); document.write(d instanceof Object + "<br>"); Thanks.
5
by: Beginner | last post by:
What is the c++ version of instanceof()? Thank-you
4
by: Sean Inglis | last post by:
Well bizarre to me, anyway. I've distilled it down to two small files: testtop.htm =============================== <html> <head> <script language="Javascript">
2
by: System Administrator | last post by:
Hi: Can someone explain why BOTH of the following are true ? Function instanceof Object //true Object instanceof Function //true (Either one or the other should be true, not both,...
2
by: System Administrator | last post by:
function a() { } typeof a //returns 'function' a instanceof a //returns false typeof Object //returns 'function' Object instanceof Object //returns ...
15
by: shana07 | last post by:
Can I have many instanceof code for one 'if' ? for example..... if(checkMe instanceof AInstruction instanceof LocVariableInst) What I am trying to say is, these instanceof are refer to these...
13
by: Robert | last post by:
Hi, Is it possible to intercept a call to "instanceof" and return something different? I wanted to see if it was possible to implement something like multiple inheritance, especially to use...
30
by: kj | last post by:
My book (Flanagan's JavaScript: The Definitive Guide, 5th ed.) implies on page 111 that the following two constructs are equivalent: ( x.constructor == Foo ) and ( x instanceof Foo ) The...
3
by: whitelined | last post by:
Hi, How widely supported is the instanceof operator? Is there an alternative to seeing if an object is an instance of a constructor? Many thanks Regards Aaron
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.