views:

43

answers:

1

Ello, Working with Workflow Foundations 4 (in C#) and trying to write a VB expression Is there a way to do the following in VB.Net on one line?

SomeObj instance = new SomeObj()
{ 
    SomeStringProp = "a",
    SomeIntProp = 17
};
+4  A: 

Here's an example

Dim instance = new SomeObj() With {.ISomeStringProp = "a", .SomeIntProp = 17}

if you want more info take a look at this

Rune FS
+1 on the example, think the quip about google is unnecessary, though. Stackoverflow is supposed to house the answers to the difficult as well as the trivial, whether or not the answer already exists elsewhere on the interwebs.
Anthony Pegram
@Anthony I'll humor you but there's quite a precedence for commenting questions that takes longer to write than to google the answer to. And this one took longer to _read_ than to find the answer too
Rune FS
@Rune Out of curiosity what was the exact phrasing you used when googling?
Terrance
@terrance "object initializer vb.net" :)
Rune FS