문제

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

I used to construct objects like this, it there a similar way to do this in visual basic? I'm sorry I couldn't really label the technique.

도움이 되었습니까?

해결책

Object initializer in VB.NET:

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

다른 팁

The Rectangle has a constructor to define width and height:

Dim r As New Rectangle(1, 1, 200, 300) 'x,y,width,height
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top