Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/265.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/github/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
c#中带构造函数的类_C# - Fatal编程技术网

c#中带构造函数的类

c#中带构造函数的类,c#,C#,标题的结尾是什么意思 MobilePhone(string phoneNumber, string name) : this(phoneNumber) { this.name = name; } 我猜你指的是:这个(电话号码) 这基本上是第二个构造函数调用。它被称为构造函数链接 基本上有两个构造函数,其中一个调用第二个构造函数以获取其内容 //Constructor A gets called and calls constructor B MobilePhone(string num

标题的结尾是什么意思

MobilePhone(string phoneNumber, string name) : this(phoneNumber)
{
    this.name = name;
}

我猜你指的是
:这个(电话号码)

这基本上是第二个构造函数调用。它被称为构造函数链接

基本上有两个构造函数,其中一个调用第二个构造函数以获取其内容

//Constructor A gets called and calls constructor B
MobilePhone(string number, string name) : this(number) 
{
    this.name = name;
}

//This would be constructor B
MobilePhone(string number)
{
    this.number = number;
}
表示“在调用下面的代码之前,调用其他
构造函数(它使用单个
字符串
参数),将
电话号码作为参数传递给它”。

:此(电话号码)
调用另一个只接受电话号码的构造函数重载(或至少是一个
字符串
):


标题是什么?你到底指的是哪一部分?怎么不清楚?这个(电话号码)调用另一个只接受电话号码的构造函数。
this(phoneNumber)
MobilePhone(string phoneNumber, string name) : this(phoneNumber)
{
    this.name = name;
}

//this one is invoked using 'this(phoneNumber)' above
MobilePhone(string phoneNumber)
{
    this.phoneNumber = name;
}