문제

I have a simple line in C# that I'm trying to translate to VB.NET and I'm getting nowhere.

(new CMachine()).Init();

Yes, It needs to be a 1-liner because the point I'm trying to demonstrate is that an instance of CMachine need not stick around after Init() has been called. Later in the code, I demonstrate subsequent instances of CMachine have already been initialized.

FYI: New CMachine().Init() and (New CMachine()).Init() do not work.

도움이 되었습니까?

해결책

There may be a more idiomatic way of doing this, but this works:

With New CMachine
    .Init()
End With
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top