C# 我该如何做一个方法来反转4个变量的位置?
我试图创建一个程序,其中包含一个方法,可以反转四个变量的位置。编写一个主方法,演示该方法是否正确工作。我该怎么做呢?我是C的新手。我想OP正在寻找这个C# 我该如何做一个方法来反转4个变量的位置?,c#,C#,我试图创建一个程序,其中包含一个方法,可以反转四个变量的位置。编写一个主方法,演示该方法是否正确工作。我该怎么做呢?我是C的新手。我想OP正在寻找这个 static void Main(string[] args) { int first = 111; int second = 222; int third = 333; int fourth = 444; Console.WriteLine("Number
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;
}
反转四个变量的位置…要求是否更模糊?如果这是一项学校作业,而这是老师给你的全部内容,我会向他们询问更多信息。如果不是因为大写字母T,我会以为你在自言自语;我认为OP可能想重命名t并将其更改为t:Wow。。这与几分钟前发布的问题非常相似:。我希望你们俩有一天能找到一个更好的导师@国王-但我的阿凡达更好:最初的任务是什么?你们两个碰巧在一个班上吗?这完全违背了学习将完整的代码交给别人完成作业的目的。Console.WriteLineNumbers的正常顺序如何:{0},{1},{2},{3},第一,第二,第三,第四;Console.WriteLineNumbers的顺序相反:{3}、{2}、{1}、{0}、第一、第二、第三、第四;:你是不是用户用户1306322我是confused@tim你应该专注于你的作业。你能记住或找到确切的措辞并将其包含在你的问题中吗?在这里,我认为两个TIM是混乱的