c#构造函数::this(new Rect(x,y,width,height))

c#构造函数::this(new Rect(x,y,width,height))
public QuadNode(double x,double y,double width,double height)
:this(new Rect(x,y,width,height))
{
}
public class QuadNode
{
}他本身是来自这个类,他为什么要重载自己,有什么作用?
jmn6 1年前 已收到1个回答 举报

怪异的虫虫 幼苗

共回答了20个问题采纳率:95% 举报

:this()表示重载另一个需要参数为Rect的构造方法.
意思是这个类还有一个构造方法为:
public QuadNode(Rect r)
{
}
重载自己当然是为了开发方便了.
如果 两构造方法为:
public QuadNode(int a,int b,int c,int d,int e)
{
this.A=a;
.
...
}
public QuadNode(int a,int b,int c,int d,int e,int f)
:this(a,b,c,d,e)
{
this.F= f;
}
如果参数过于繁多并且作用一样的话,节省不少代码量.
有问题可以HI我.

1年前

3
可能相似的问题
Copyright © 2024 YULUCN.COM - 雨露学习互助 - 16 q. 0.023 s. - webmaster@yulucn.com