using System;
namespace CalculatorApplication {
class NumberManipulator {
public void swap(int x, int y) {
int temp;
temp = x; /* save the value of x */
x = y; /* put y into x */
y = temp; /* put temp into y */
}
static void Main(string[] args) {
NumberManipulator n = new NumberManipulator();
/* local variable deFinition */
int a = 100;
int b = 200;
Console.WriteLine(Before swap, value of a : {0}, a);
Console.WriteLine(Before swap, value of b : {0}, b);
/* calling a function to swap the values */
n.swap(a, b);
Console.WriteLine(After swap, value of a : {0}, a);
Console.WriteLine(After swap, value of b : {0}, b);
Console.ReadLine();
}
}
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。