473,513 Members | 7,598 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

operator is new in 2.0?

Hello,

I'm reading this book (Self-Paced for 70-536) where it says that operators
are new both to VB:NET and C#. As far as i know operators exist for C# since
1.x and this link says so too:

http://msdn.microsoft.com/library/de...rfoperator.asp

So, the book is wrong? or am i mistaking concepts?
TIA
Jul 8 '06 #1
3 1282
Alexander,

C# definitely supported operator overloading from 1.0 on. I think it is
just now that VB will honor the special naming convention for operators (I
don't think that the first incarnation of VB.NET did).

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Alexander Ubillus" <al********@hotmail.comwrote in message
news:%2****************@TK2MSFTNGP05.phx.gbl...
Hello,

I'm reading this book (Self-Paced for 70-536) where it says that operators
are new both to VB:NET and C#. As far as i know operators exist for C#
since 1.x and this link says so too:

http://msdn.microsoft.com/library/de...rfoperator.asp

So, the book is wrong? or am i mistaking concepts?
TIA

Jul 8 '06 #2
Thank you Nicholas,

So then, the book is wrong? because it says "new in framework 2.0" instead
of "new for vb 2005"
this is exactly what is says:

For VB.NET

Public Function ToInteger() As Integer
Return Value
End Function

' Operators (new in 2.0)
Public Shared Operator +(ByVal arg1 As Cycle, ByVal arg2 As Integer) As
Cycle
arg1.Value += arg2
Return arg1
End Operator

Public Shared Operator -(ByVal arg1 As Cycle, ByVal arg2 As Integer) As
Cycle
arg1.Value -= arg2
Return arg1
End Operator

and the same for C#
//
....
public int ToInteger()
{
return Value;
}
// Operators (new in .NET 2.0)
public static Cycle operator +(Cycle arg1, int arg2)
{
arg1.Value += arg2;
return arg1;
}
public static Cycle operator -(Cycle arg1, int arg2)
{
arg1.Value -= arg2;
return arg1;
}
....
//

I just wanted to clarify this, so other readers doesn't get confused (or
fail) when the time comes to answer the exam questions.

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.comescribió
en el mensaje news:ec**************@TK2MSFTNGP04.phx.gbl...
Alexander,

C# definitely supported operator overloading from 1.0 on. I think it
is just now that VB will honor the special naming convention for operators
(I don't think that the first incarnation of VB.NET did).

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Alexander Ubillus" <al********@hotmail.comwrote in message
news:%2****************@TK2MSFTNGP05.phx.gbl...
>Hello,

I'm reading this book (Self-Paced for 70-536) where it says that
operators are new both to VB:NET and C#. As far as i know operators exist
for C# since 1.x and this link says so too:

http://msdn.microsoft.com/library/de...rfoperator.asp

So, the book is wrong? or am i mistaking concepts?
TIA


Jul 8 '06 #3
Alexander,

I think it depends on the context, which is ambiguous in this case. If
they mean for just VB.NET, then yes, it is right. I think that is what the
author meant, "new in the framework 2.0 for VB.NET".
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Alexander Ubillus" <al********@hotmail.comwrote in message
news:uH****************@TK2MSFTNGP03.phx.gbl...
Thank you Nicholas,

So then, the book is wrong? because it says "new in framework 2.0" instead
of "new for vb 2005"
this is exactly what is says:

For VB.NET

Public Function ToInteger() As Integer
Return Value
End Function

' Operators (new in 2.0)
Public Shared Operator +(ByVal arg1 As Cycle, ByVal arg2 As Integer) As
Cycle
arg1.Value += arg2
Return arg1
End Operator

Public Shared Operator -(ByVal arg1 As Cycle, ByVal arg2 As Integer) As
Cycle
arg1.Value -= arg2
Return arg1
End Operator

and the same for C#
//
...
public int ToInteger()
{
return Value;
}
// Operators (new in .NET 2.0)
public static Cycle operator +(Cycle arg1, int arg2)
{
arg1.Value += arg2;
return arg1;
}
public static Cycle operator -(Cycle arg1, int arg2)
{
arg1.Value -= arg2;
return arg1;
}
...
//

I just wanted to clarify this, so other readers doesn't get confused (or
fail) when the time comes to answer the exam questions.

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com>
escribió en el mensaje news:ec**************@TK2MSFTNGP04.phx.gbl...
>Alexander,

C# definitely supported operator overloading from 1.0 on. I think it
is just now that VB will honor the special naming convention for
operators (I don't think that the first incarnation of VB.NET did).

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Alexander Ubillus" <al********@hotmail.comwrote in message
news:%2****************@TK2MSFTNGP05.phx.gbl...
>>Hello,

I'm reading this book (Self-Paced for 70-536) where it says that
operators are new both to VB:NET and C#. As far as i know operators
exist for C# since 1.x and this link says so too:

http://msdn.microsoft.com/library/de...rfoperator.asp

So, the book is wrong? or am i mistaking concepts?
TIA



Jul 8 '06 #4

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

Similar topics

7
8018
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
3855
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
4402
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
2273
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
3254
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,...
0
7153
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
7373
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,...
0
7432
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
5677
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5079
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
4743
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3218
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1585
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 ...
1
796
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.