我如何在托管C ++中做typeof(int)? [英] How do I do typeof(int) in Managed C++?
问题描述
我正在开发一个项目,其中一部分使用托管C ++。在托管C ++代码中,我创建了一个DataTable。在定义数据表的列时,我需要指定列的类型。在C#中,这将是:
I am working on a project now and part of it uses Managed C++. In the managed C++ code, I am creating a DataTable. While defining the Columns for the datatable, I need to specify the Type of the column. In C#, that would:
typeof(int)
typeof(int)
但是如何在托管C ++?
but how do I do that in Managed C++?
谢谢!
推荐答案
在C ++ / CLI,使用typeid关键字。
In C++/CLI, use the typeid keyword.
例
Type ^t = Int32::typeid;
在旧版的Managed C ++ Extensions语法中,您可以使用 __ typeof (Int32)
,但该语言的整个版本被严重废弃,你应该使用C ++ / CLI。
In the older "Managed C++ Extensions" syntax, you'd use __typeof(Int32)
, but that whole version of the language is severely deprecated and you should be using C++/CLI.
这篇关于我如何在托管C ++中做typeof(int)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!