是否有一个等同于C#" VAR"在C ++ / CLI关键字?有一个、关键字、VAR、QUOT

由网友(半生酒醒)分享简介:在C#中,我喜欢的 VAR 关键字这样的情况:In C#, I like the var keyword for situations like this:var myList = new List();有没有在C ++ / CLI任何等价的,还是我要重复的类型名称每次只是这样的:Is there...

在C#中,我喜欢的 VAR 关键字这样的情况:

In C#, I like the var keyword for situations like this:

var myList = new List<MyType>();

有没有在C ++ / CLI任何等价的,还是我要重复的类型名称每次只是这样的:

Is there any equivalent in C++/CLI, or do I have to repeat the type name everytime just like this:

List<MyType ^>^ myList = gcnew List<MyType ^>();

无法找到一个明确的声明在文档或谷歌至今。我使用的Visual Studio 2008。

Could not find an explicit statement in the docs or by Google so far. I am using Visual Studio 2008.

推荐答案

在Visual Studio 2008中有没有这样的等价物。然而,随着Visual Studio 2010中,你可以使用汽车关键字实施 VAR 就像在C ++中的语义。我知道这工作与非托管C ++和我相当肯定它适用于C ++ / CLI为好。

In Visual Studio 2008 there is no such equivalent. However with Visual Studio 2010 you can use the auto keyword to implement var like semantics in C++. I know this works with non-managed C++ and I'm fairly certain it works for C++/CLI as well.

阅读全文

相关推荐

最新文章