سؤال

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