重新排列参数

重新排列参数操作可以使你重新排列方法、索引器中的参数。你将方法的参数重新排列后,所有使用该方法的地方都会相应调整。以下面代码为例:

class Person
{
public void Print(string name, int age, bool sex)
{
}
}
class Program
{
static void Main(string[] args)
{
Person p = new Person();
p.Print("妞妞",28,false);
}
}

将光标放置在“Print”方法上使用“重新排列参数”命令,将会弹出下面对话框(29.16):

重新排列参数 
图29.16  重构参数

此时你可以使用右边的上移箭头和下移箭头调整参数的顺序,如上调整后,代码更新如下,其中方法的声明和使用部分参数都被更新:

class Person
{
public void Print(int age, string name, bool sex)
{
}
}
class Program
{
static void Main(string[] args)
{
Person p = new Person();
p.Print(28, "妞妞", false);
}
}

相关文章:

  • 2021-05-19
  • 2022-01-21
  • 2022-12-23
  • 2022-12-23
  • 2021-11-09
  • 2022-12-23
  • 2021-05-07
猜你喜欢
  • 2022-02-18
  • 2022-12-23
  • 2022-12-23
  • 2021-05-20
  • 2021-06-17
  • 2021-08-09
  • 2021-05-19
相关资源
相似解决方案