Confusing between Native and Managed !??
-
Hi If i use /clr mode to compile a code that has somthing like the following:
int x = 3;
char ch='A';
int arr[]="Hi";
array^ ManArr1={44};
array^ ManArr2= gcnew array {44};my questions now: Would the type
int
be mapped toSystem::Int32
?? and what aboutchar ch
? Are they considerd as native or managed type? Where will be executed! through MSIL or not!! We see thatint arr[]
is a native array, does that mean it will be executed out of MSIL?:confused: The last question ;) ,, For both the managed array ManArr1 & ManArr2 what is the difference between the two initialization ?? -
Hi If i use /clr mode to compile a code that has somthing like the following:
int x = 3;
char ch='A';
int arr[]="Hi";
array^ ManArr1={44};
array^ ManArr2= gcnew array {44};my questions now: Would the type
int
be mapped toSystem::Int32
?? and what aboutchar ch
? Are they considerd as native or managed type? Where will be executed! through MSIL or not!! We see thatint arr[]
is a native array, does that mean it will be executed out of MSIL?:confused: The last question ;) ,, For both the managed array ManArr1 & ManArr2 what is the difference between the two initialization ??Good question!
anti.AS wrote:
Would the type int be mapped to System::Int32
Yes. By default compiler treat it as managed integer. And what type of interger is implementation defined. On a 32 bit machine you could get
System.Int32
and Int64 on 64 bit machines. Now consider the following exampleint x = 3;
std::cout << x;std::cout
expects a native integer and you are passing a managed one. So the compiler does the conversion for you.anti.AS wrote:
and what about char ch ?
This will be compiled as
System.SByte
.anti.AS wrote:
We see that int arr[] is a native array
int arr[]="Hi";
is an invalid statement. But in general, this is treated as a managed CLI array.anti.AS wrote:
The last question Wink ,, For both the managed array ManArr1 & ManArr2 what is the difference between the two initialization ??
Nothing. First one is a syntactic sugar. Hope that helps :)
Best wishes, Navaneeth
-
Good question!
anti.AS wrote:
Would the type int be mapped to System::Int32
Yes. By default compiler treat it as managed integer. And what type of interger is implementation defined. On a 32 bit machine you could get
System.Int32
and Int64 on 64 bit machines. Now consider the following exampleint x = 3;
std::cout << x;std::cout
expects a native integer and you are passing a managed one. So the compiler does the conversion for you.anti.AS wrote:
and what about char ch ?
This will be compiled as
System.SByte
.anti.AS wrote:
We see that int arr[] is a native array
int arr[]="Hi";
is an invalid statement. But in general, this is treated as a managed CLI array.anti.AS wrote:
The last question Wink ,, For both the managed array ManArr1 & ManArr2 what is the difference between the two initialization ??
Nothing. First one is a syntactic sugar. Hope that helps :)
Best wishes, Navaneeth