Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / May 2007

Tip: Looking for answers? Try searching our database.

Unary plus

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Michael A. Covington - 12 May 2007 16:19 GMT
Other than to create confusion, does the unary plus operator serve any
purpose at all?

All C# numeric types have a unary plus.  The syntax is something like:

x = +y;

where +y is the same value as y, whether positive or negative.
Chris Nahr - 12 May 2007 16:34 GMT
Well, you can use it to neatly line up positive and negative values in
a monospaced font... other than that I don't know!
--
http://www.kynosarges.de
Bob Grommes - 13 May 2007 03:42 GMT
Michael,

This is one of those things where any reference you care to hunt down
quotes the same exact definition, which tells me that no one has a
coherent explanation.  It is probably an item of esoterica that's thrown
in for "completeness" from the perspective of the language designer, but
I can't think of a use for us mere mortals, except that tutorials feel
obligated to mention it because it's there ;-)

--Bob

> Other than to create confusion, does the unary plus operator serve any
> purpose at all?
[quoted text clipped - 4 lines]
>
> where +y is the same value as y, whether positive or negative.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.