I am trying to create a program which contains a method that reverses the positions of four variables. Write a Main() method that demonstrates the method works correctly. How would I go about doing this I'm new to C#.
问问题
105 次
1 回答
0
我认为 OP 正在寻找这个
static void Main(string[] args)
{
int first = 111;
int second = 222;
int third = 333;
int fourth = 444;
Console.WriteLine("Numbers in normal order: {0},{1},{2},{3}", first, second, third, fourth);
Reverse(ref first, ref second, ref third, ref fourth);
Console.WriteLine("Numbers in inverse order: {0},{1},{2},{3}", first, second, third, fourth);
Console.WriteLine("Press Enter To Exit");
Console.ReadLine();
}
public static void Reverse(ref int first1, ref int second2, ref int third3, ref int fourth4)
{
int temp, temp1;
temp = first1;
first1 = fourth4;
temp1 = second2;
second2 = third3;
third3 = temp1;
fourth4 = temp;
}
于 2013-09-03T05:50:57.213 回答