Skip to content

Object array declaration and initialisation

akaii de Shangaii

Asked Jan 10, 2006, 2:42 AM EST2 answers
Share
LinkedInX
 hello
I need to pass an array of the object com.phone.www.info in a function so I'm trying to create an instance of this object like this:
com.phone.www.Info[] inf = new com.phone.www.Info() ;

I get this error message:
Error 1 Cannot implicitly convert type 'PBX_Admin_Console.com.innovaphone.www.Info' to 'PBX_Admin_Console.com.phone.www.Info[]' C:\Documents and Settings\xavier\My Documents\Visual Studio 2005\Projects\PBX_Admin_Console\PBX_Admin_Console\Form1.cs 29 42 PBX_Admin_Console

Does somebody have an idea about what I did wrong?

1 Answer

Know the answer? Post it. Somebody with the same question will find it here.

  • 0

    You cannot convert from object to object array. Thats very clear. This is the way you create object array:

    Code
    
    int size = 10;
    
    com.phone.www.Info[] inf = new com.phone.www.Info[size];
    Or you can use .NET 2.0 feature, System.Collections.Generic.List<>:
    List<com.phone.www.Info> infos = new List<com.phone.www.Info>();
    0
  • 1 short reply