views:

203

answers:

2

Possible Duplicate:
Anonymous class initialization in VB.Net

Trying to convert examples like this from C# to VB.Net leaved me scratching my already bald head...:

public ActionResult GridData(string sidx, string sord, int page, int rows) {
  var jsonData = new {
    total = 1, // we'll implement later 
    page = page,
    records = 3, // implement later 
    rows = new[]{
      new {id = 1, cell = new[] {"1", "-7", "Is this a good question?"}},
      new {id = 2, cell = new[] {"2", "15", "Is this a blatant ripoff?"}},
      new {id = 3, cell = new[] {"3", "23", "Why is the sky blue?"}}
    }
  };
  return Json(jsonData);
}

My problem is, how can I fill the jsonData variable in a similar way in VB.Net - even with sub-arrays(rows)?

How can I fill do the same thing as this - but in VB.Net?

I have switched from VB.Net to C# for future projects, because there is so much more sourcecode and examples out there in C#... But for now I still have to work on several VB.Net projects, so I keep running into these challenges.

Code is from Haack's blogpost on doing JqGrid in ASP.Net MVC.

+2  A: 

See this exact duplicate post.

bdukes
A: 

On SO, I found this

http://stackoverflow.com/questions/407586/what-is-the-vb-net-code-equivelant-for-c-anonymous-type-code

http://stackoverflow.com/questions/85892/collection-initialization-syntax-in-vb-2008

shahkalpesh
Those posts are about anonymous types and collection initialization in VB.NET, however, the question focuses on anonymous array initialization, which is slightly different than either of those (and not directly supported in VB.NET 9).
bdukes
@bdukes: If I look at the code, it tries to use anonymous types
shahkalpesh
@bdukes: Isn't an array, a collection?
shahkalpesh