Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I do typeof(int) in Managed 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)

but how do I do that in Managed C++?

Thanks!

like image 946
Nazeeh Avatar asked Jul 15 '09 18:07

Nazeeh


People also ask

What does typeof () return in C?

In other languages, such as C# or D and, to some degree, in C (as part of nonstandard extensions and proposed standard revisions), the typeof operator returns the static type of the operand. That is, it evaluates to the declared type at that instant in the program, irrespective of its original form.

Is there typeof in C?

The typeof keyword is a new extension to the C language. The Oracle Developer Studio C compiler accepts constructs with typeof wherever a typedef name is accepted, including the following syntactic categories: Declarations.

What is managed C++ code?

Managed C++ is a language invented by Microsoft, that compiles to bytecode run by the . NET Framework. It uses mostly the same syntax as C++ (hence the name) but is compiled in the same way as C# or VB.NET; basically only the syntax changes, e.g. using '->' to point to a member of an object (instead of '.


1 Answers

In C++/CLI, use the typeid keyword.

e.g.

Type ^t = Int32::typeid; 

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.

like image 147
Daniel Earwicker Avatar answered Sep 29 '22 15:09

Daniel Earwicker