Click here to Skip to main content
15,880,967 members
Articles / Programming Languages / C#
Alternative
Tip/Trick

Swaping values of two variable without temporary variable

Rate me:
Please Sign up or sign in to vote.
3.00/5 (2 votes)
17 Mar 2010CPOL 6.2K   1  
There is also InterlockedExchange (or your operating system's equivalent).long a = 1;long b = 2;b = InterlockedExchange(&a, b);
There is also InterlockedExchange (or your operating system's equivalent).

MIDL
long a = 1;
long b = 2;
b = InterlockedExchange(&a, b);

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer Web Biscuit
United Kingdom United Kingdom
At Web Biscuit, you can find software, articles, a good dollop of quality and an unhealthy obsession over biscuits.
Website: http://www.webbiscuit.co.uk
Twitter Watch: http://twitter.com/WebBiscuitCoUk

Comments and Discussions

 
-- There are no messages in this forum --