473,467 Members | 1,860 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Equals Operator

What did MS not take the chance to change
the silly == operator when they designed C#,
to something reasonable like = ?
Why change the universal meaning of = ?

Wouldn't it be better to have:
Assignment := //or something else
Equal = //but keep = to be =

My view,
Roger
Nov 17 '05 #1
3 1427
Roger <ro***@pcsrevenuecontrol.com> wrote:
What did MS not take the chance to change
the silly == operator when they designed C#,
to something reasonable like = ?
Why change the universal meaning of = ?

Wouldn't it be better to have:
Assignment := //or something else
Equal = //but keep = to be =


Because it's not the universal meaning of =. In particular, that's not
the meaning of = in C, C++ or Java, which is what the syntax of C# is
based on.

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

The language is called C#. Much of the syntax is taken from C/C++ design. I
lot of the problems that were caused by == in C / C++ are caught be the C#
compiler. You can't get away with stuff like:

if (a = b)

In most cases this is a typo in C / C++ but the comiler wouldn't flag it. If
[b] was zero it would come out false else it would be true. C# will yell at
you if you try this.

Problem solved.

"Roger" <ro***@pcsrevenuecontrol.com> wrote in message
news:OP**************@tk2msftngp13.phx.gbl...
What did MS not take the chance to change
the silly == operator when they designed C#,
to something reasonable like = ?
Why change the universal meaning of = ?

Wouldn't it be better to have:
Assignment := //or something else
Equal = //but keep = to be =

My view,
Roger

Nov 17 '05 #3

"Roger" <ro***@pcsrevenuecontrol.com> wrote in message
news:OP**************@tk2msftngp13.phx.gbl...
What did MS not take the chance to change
the silly == operator when they designed C#,
to something reasonable like = ?
Why change the universal meaning of = ?

Wouldn't it be better to have:
Assignment := //or something else
Equal = //but keep = to be =

My view,
Roger


I also think pascal style makes more sense.

As I'm used to Delphi I typically assign when I should compare, which makes
for some funny bugs when I have (the misfortune) to code in C/C++. My Bad.

But as C# protects you from doing stupid things with assignments, it's no
big deal.
And as I do 99% of my coding in C# nowadays, I seldom make these kind of
mistakas anymore.

- Michael S
Nov 17 '05 #4

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

Similar topics

2
by: emma middlebrook | last post by:
Hi Having difficulty getting myself clear on how a type's operator== fits in with Object.Equals. Let's just consider reference types. The default operator== tests for object identity...
4
by: Kurt | last post by:
Wouldn't you agree all of the follwoing should produce the same result? r = (o1 == o2); r = (o2 == o1); r = object.Equals(o1, o2); r = object.Equals(o2, o1); r = (o1.Equals(o2)); r =...
4
by: Chris | last post by:
This is something that has been bugging me for some time. When exactly should I be using == instead of .Equals() ? I see a lot of code that performs object evaluation e.g. Is Object1 the same as...
12
by: cody | last post by:
Why can I overload operator== and operator!= separately having different implementations and additionally I can override equals() also having a different implementation. Why not forbid...
10
by: r035198x | last post by:
The Object class has five non final methods namely equals, hashCode, toString, clone, and finalize. These were designed to be overridden according to specific general contracts. Other classes that...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.