1.命名构造函数
class Rect
{
const Rect.posAndSize(this.pos, this.size); //命名构造函数
/// Gets the empty rectangle.
static const empty = Rect.posAndSize(Vec.zero, Vec.zero);
}
c#改写:可以使用静态函数:
public static RoomTile Junction(Direction direction)
{
var rtn = new RoomTile()
{
tile = null,
direction = direction
};
return rtn;
}
网友评论