程序,从名字和姓氏切换到姓氏,然后是名字.你能帮忙解决一下吗?

use*_*261 -1 c#

我在firstName和lastName收到错误"冲突变量定义如下".

另外'从不使用局部变量fi​​rstName,在此范围内不能声明名为firstName的局部变量....等'

编辑=这不是家庭作业,只是我正在使用的书中的练习.

http://pastebin.com/zNiuUCkd

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MethodsPractice
{
class Program
{
     static string SwitchName(string x, string y)
     {

         string firstName = x;
         string lastName = y;

         string temp = firstName;

        firstName = lastName;
        lastName = temp;

        string final = ("{0},{1}", firstName, lastName)



        return final;

    }


    static void Main(string[] args)
    {
        string nameReversed = "";
        string first = "Tim";
        string last = "Stern";
        nameReversed = SwitchName(first, last);

        Console.WriteLine(nameReversed);
        Console.ReadKey(true);

    }


   }
}
Run Code Online (Sandbox Code Playgroud)

谢谢

Ton*_*son 6

要么

 static string SwitchName(string firstname, string lastname)
 {
    return String.Format("{0},{1}", lastname, firstName)
 }
Run Code Online (Sandbox Code Playgroud)