等效的"rectangle a=new a() {width=1;身高= 2;}“

本文关键字:width 身高 new quot rectangle | 更新日期: 2023-09-27 18:03:33

rectangle a=new a() { width=1; height=2; }

我曾经这样构造对象,在visual basic中有类似的方法吗?我很抱歉我不能真正地标记这项技术。

等效的"rectangle a=new a() {width=1;身高= 2;}“

VB中的对象初始化器。净:

Dim a = New Rectangle With { .width = 1, .height = 2 }

Rectangle有一个定义宽度和高度的构造函数:

Dim r As New Rectangle(1, 1, 200, 300) 'x,y,width,height