Casting Interger to System::Object

  • Thread starter Thread starter Neil Guyette
  • Start date Start date
N

Neil Guyette

Hi, All,

I'm using a COM object in my application, one of the
methods require a System::Object as a parameter. I need
to pass in a int, therefore I need to cast the int value
as a System::Object but I haven't figured out how to
approach this problem.

//Code sample

Interop::SQLDMO.ApplicationClass *sqlApp;
Interop::SQLDMO.NameList *sqlList;

sqlList = sqlApp.ListSqlServers();
for(int i = 0; i < sqlList.Count; i++)
cmbSqlList.Item.Add(sqlList.Item((System::Object)i);

//the last statement errors because I can't cast int (i)
//to a System::Object. How can this be done?????

Thanks,

-Neil
 
Neil said:
I'm using a COM object in my application, one of the
methods require a System::Object as a parameter. I need
to pass in a int, therefore I need to cast the int value
as a System::Object but I haven't figured out how to
approach this problem.

cmbSqlList.Item.Add(sqlList.Item((System::Object)i);

//the last statement errors because I can't cast int (i)
//to a System::Object. How can this be done?????
cmbSqlList.Item.Add(sqlList.Item( __box(i) );


--
Greetings
Jochen

Do you need a memory-leak finder ?
http://www.codeproject.com/tools/leakfinder.asp
 
Back
Top