鉴于下面的代码,position0初始化方式和初始化方式之间有什么区别position1?它们是等价的吗?如果没有,有什么区别?
class Program
{
static void Main(string[] args)
{
Position position0 = new Position() { x=3, y=4 };
Position position1 = new Position();
position1.x = 3;
position1.y = 4;
}
}
struct Position
{
public int x, y;
}
Run Code Online (Sandbox Code Playgroud)