How to

exchange two numerical variables without the third var

Published: 31. January 2012 | Updated: 31. January 2012
License: Microsoft Public License (MS-PL)
Categories: Framework
Tags: C#
Was this snippet helpful for you? YESYES / NONO
int a = 164895;
int b = -45;

a = a + b;
b = a - b;
a = a - b;

Console.WriteLine(a);
Console.WriteLine(b);
Console Output:
-45
164895
Send us feedback about this snippet »



Related Snippets: