Export (0) Print
Expand All
0 out of 1 rated this helpful - Rate this topic

Standard Conversions and Implicit Boxing

A standard conversion will be chosen by the compiler over a conversion that requires boxing.

// clr_implicit_boxing_Std_conversion.cpp
// compile with: /clr
int f3(int ^ i) {   // requires boxing
   return 1;
}

int f3(char c) {   // no boxing required, standard conversion
   return 2;
}

int main() {
   int i = 5;
   System::Console::WriteLine(f3(i));
}

Output

2
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.