Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / Languages / C#

Swaping values of two variable without temporary variable

3.00/5 (2 votes)
17 Mar 2010CPOL 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)