473,385 Members | 1,402 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,385 software developers and data experts.

Is Operator

The Is operator determines if two object references refer to the same object.
If object1 and object2 both refer to the same object, result is True; if they do not, result is False.

Check the code below , both objects refer to the same object,but the answer is coming false.Example
Module Module1
Public Class base

End Class
Sub main()
Dim obj As New base
Dim obj1 As New base
Dim check As Boolean
check = obj Is obj1
Console.WriteLine(check)
Console.ReadLine()
End Sub
End Module
Mar 28 '08 #1
1 821
balabaster
797 Expert 512MB
Dim obj As New base
Dim obj1 As New base
Dim check As Boolean
check = obj Is obj1
Console.WriteLine(check)
Console.ReadLine()
You're missing the point obj and obj1 are both of type "Base" but they're not referring to the same object.

Dim obj1 As New Base
Dim obj2 As New Base

is not the same as

Dim obj1 As New Base
Dim obj2 As Base = obj1

What you're trying to do is say are both my objects of the type Base and what you're actually asking is are both my objects the same - i.e. identical.

Assume (for argument's sake) I have an identical twin called Bob.
Bob != Ben; Bob might look like Ben, sound like Ben, act like Ben, but we're not the same person. Does that make sense? You are referring to two different entities that for the purpose of example may look identitcal, feel identical and act identically, but they're not the same entity.

You would need some kind of compare function to see if the two objects are equal - when I say equal, I mean logically equal - i.e. do all the properties of the two objects hold matching values?
Mar 28 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: Paul Davis | last post by:
I'd like to overload 'comma' to define a concatenation operator for integer-like classes. I've got some first ideas, but I'd appreciate a sanity check. The concatenation operator needs to so...
1
by: joesoap | last post by:
Hi can anybody please tell me what is wrong with my ostream operator??? this is the output i get using the 3 attached files. this is the output after i run assignment2 -joesoap #include...
6
by: YUY0x7 | last post by:
Hi, I am having a bit of trouble with a specialization of operator<<. Here goes: class MyStream { }; template <typename T> MyStream& operator<<(MyStream& lhs, T const &)
5
by: raylopez99 | last post by:
I need an example of a managed overloaded assignment operator for a reference class, so I can equate two classes A1 and A2, say called ARefClass, in this manner: A1=A2;. For some strange reason...
3
by: y-man | last post by:
Hi, I am trying to get an overloaded operator to work inside the class it works on. The situation is something like this: main.cc: #include "object.hh" #include "somefile.hh" object obj,...
1
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
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...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

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.