Public partial class Form1: Form
{
Public _click ()//the default structure parameter
{
InitializeComponent();
}
Public _click (string filePath) : this ()//take the full path constructor
{
File. The Open (filePath, FileMode. Open);
}
Public _click (string filePath, string [] Para) : this ()//take synthetic route constructor
{
String FilePath=Path.Com bine (FilePath string. Join (", ", Para));
File. The Create (FilePath);
File. The Open (FilePath, FileMode. Open);
}
}
The above content is no problem, but not enough concise, to code reuse, I want to be is in the third constructor referenced in the second constructor, similar to the following code
Public _click (string filePath, string [] Para) : this ()//take synthetic route constructor
{
String FilePath=Path.Com bine (FilePath string. Join (", ", Para));
File. The Create (FilePath);
_click (FilePath);//this is clearly wrong, for realizing the function of the code
//this (FilePath), it is also wrong!
}
Excuse me, master how to implement, the File. The Open () represents a lot of code process
CodePudding user response:
Public _click (string filePath, string [] Para) : this (filePath)//need to synthetic path constructor{
String FilePath=Path.Com bine (FilePath string. Join (", ", Para));
File. The Create (FilePath);
File. The Open (FilePath, FileMode. Open);
}
CodePudding user response:
Overloaded constructor can call each otherPublic _click (string filePath) : this (string xx, xx) string
CodePudding user response:
public partial class Form1: Form
{
Public _click ()//the default structure parameter
{
InitializeComponent();
}
Public _click (string filePath) : this (filePath, null)//with the full path constructor
{
}
Public _click (string filePath, string [] Para) : this ()//take synthetic route constructor
{
If (Para!=null)
{
FilePath=Path.Com bine (filePath string. Join (", ", Para));
}
File. The Create (filePath);
File. The Open (filePath, FileMode. Open);
}
}
CodePudding user response:
The