相关疑难解决方法(0)

C#新语句后做什么呢?

鉴于下面的代码,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)

.net c# new-operator

60
推荐指数
3
解决办法
3万
查看次数

标签 统计

.net ×1

c# ×1

new-operator ×1