R rua17 Nov 13, 2003 #1 Can anyone tell me what's the command in c# that is equivalent to the instanceOf in java? thanks
M Mattias Sjögren Nov 13, 2003 #2 Can anyone tell me what's the command in c# that is equivalent to the instanceOf in java? Click to expand... The 'is' operator if ( obj is SomeType ) Mattias
Can anyone tell me what's the command in c# that is equivalent to the instanceOf in java? Click to expand... The 'is' operator if ( obj is SomeType ) Mattias
R rua17 Nov 13, 2003 #3 thanks AlexS said: Check GetType and TypeOf x instanceOf y will be x.GetType()==y.GetType(); or TypeOf(x)==TypeOf(y); HTH Alex Click to expand...
thanks AlexS said: Check GetType and TypeOf x instanceOf y will be x.GetType()==y.GetType(); or TypeOf(x)==TypeOf(y); HTH Alex Click to expand...
J Jeff Louie Nov 14, 2003 #4 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
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
A AlexS Nov 14, 2003 #5 Check GetType and TypeOf x instanceOf y will be x.GetType()==y.GetType(); or TypeOf(x)==TypeOf(y); HTH Alex
Check GetType and TypeOf x instanceOf y will be x.GetType()==y.GetType(); or TypeOf(x)==TypeOf(y); HTH Alex
J Jon Skeet [C# MVP] Nov 14, 2003 #6 AlexS said: Check GetType and TypeOf x instanceOf y will be x.GetType()==y.GetType(); or TypeOf(x)==TypeOf(y); Click to expand... 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".
AlexS said: Check GetType and TypeOf x instanceOf y will be x.GetType()==y.GetType(); or TypeOf(x)==TypeOf(y); Click to expand... 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".