C# 关于构造函数引证次序讨教

关于构造函数,以下内容是我已经知道的:

public partial class Form1 : Form
{
public Form1() //默认构造参数
{
InitializeComponent();
}
public Form1(string filePath) : this() //带全路径构造函数
{
File.Open(filePath, FileMode.Open);
}
public Form1(string filePath, string[] Para) : this() //需合成路径构造函数
{
string FilePath = Path.Combine(filePath, string.Join(",", Para));
File.Create(FilePath);
File.Open(FilePath, FileMode.Open);
}
}

 

上面内容是没问题的,但不够简洁,为了代码能够重复使用,我想达到的目标是在第三个构造函数中引用第二个构造函数,类似于下面的代码

public Form1(string filePath, string[] Para) : this() //需合成路径构造函数
{
string FilePath = Path.Combine(filePath, string.Join(",", Para));
File.Create(FilePath);
Form1(FilePath); //这句明显不对,求实现本功能的代码
//this(FilePath),这句也不对!
}

posted @ 2020-08-07 18:32  老猿一只  阅读(167)  评论(0编辑  收藏  举报
超越台 网站制作 软件开发