C# 如何引用另一个构造函数?

C# 如何引用另一个构造函数?,c#,constructor,C#,Constructor,如何在c#中引用另一个构造函数?比如说 class A { A(int x, int y) {} A(int[] point) { how to call A(point.x, point.y}? ) } 您可以在“派生”构造函数中使用关键字this,调用“this”构造函数: class A { A(int x, int y) {} A(int[] point) : this(point[0], point[1]) { //us

如何在c#中引用另一个构造函数?比如说

class A
{
    A(int x, int y) {}

    A(int[] point)
    {
      how to call A(point.x, point.y}?
    )
}

您可以在“派生”构造函数中使用关键字
this
,调用“this”构造函数:

class A
{
    A(int x, int y) {}

    A(int[] point) : this(point[0], point[1]) { //using this to refer to its own class constructor
    {

    }    
}

除此之外,我认为您应该通过索引获取数组中的值:
点[0],点[1]
,而不是像获取字段/属性那样执行:
点.x,点.y

这非常简单。和调用基构造函数的方式相同

A(int[] point) : this(point[0], point[1])
{
}

你可以在构造函数中使用
关键字
这个
,它不是
构造函数。我从来没说过这个?啊,对不起。我看错了。不,那是一个
这个
构造函数,不是
构造函数。