【发布时间】:2012-08-22 20:11:26
【问题描述】:
我想用这种语法在 C# 中获得相同的结果,但在 VB.NET 中:
// This is my generic object (coming from Json parsing!):
var genericContent = new { Name = "name1", Value = 0 };
// I would like to have a generic list, created by this generic item:
var myList = (new[] { genericContent }).ToList();
// So, I can add any other generic items (with the same structure)...
myList.Add(new { Name = "name2", Value = 1 });
// And treat them as a normal list, without declaring the class!
return myList.Count;
...所以,我只想在 VB 中创建一个通用数组。
在 C# 中它运行良好,但我不知道这种 VB.NET 语法...
我正在使用 .NET 框架 3.5!
谢谢!
【问题讨论】:
-
'好吧,到目前为止你尝试了什么? VS 提供了一个非常方便的智能感知,如果使用得当,它真的很有帮助......
-
@BigYellowCactus,你是对的,但没有人说他不能访问谷歌,对吧?如果他至少尝试过将智能感知+谷歌结合起来,他很快就会得到答案,而不会在这里浪费我们和他的时间,你不觉得吗?现在他的问题看起来像 -
hey, I need THIS, but I don't want to do it, so do it for me people!