Error: Argument 1: cannot convert from 'int?[]' to 'object[]'

Jennifer Weinman Douglas

I'm trying to create a report with Visual Studio 2012, MVC 4, C# and the built in reporting system. I'm using a stored procedure to union and join about 13 tables I know this is me just having a brain dead moment, but as I'm trying to populate an array from a stored procedure into a ddl, I'm having issues with the following error:

Argument 1: cannot convert from 'int?[]' to 'object[]'

Here is the code:

public frm100percentQA()
{
        InitializeComponent();
        this.comboBox2.Visible = true;
        this.comboBox2.Items.Clear();
        List<Int32?> users = (from c in new NHISLINQ.NHISLINQDataContext().sp100PercentlQualityAssurance() where c.UserID != '0' select c.UserID).ToList();
        this.comboBox2.Items.Add("<---Select UserID--->");
        this.comboBox2.Items.Add("Select All");
        this.comboBox2.Items.AddRange(users.ToArray());
        this.comboBox2.SelectedIndex = 0;
}

I know it's probably a fairly simple solution, but I'm drawing a blank at this point. Any help?

Kenneth

The problem is that you can't add an Int-array to an Object-array. Although you might think this should be possible, it's not. This is called Covariance.

You should first cast all values to object before you add them to the object-array. You can do that using Linq in one line:

this.comboBox2.Items.AddRange(users.Cast<object>().ToArray());

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

cannot convert argument 1 from int to int && error

From Dev

cannot convert argument 1 from int to int && error

From Dev

Argument1: cannot convert from 'string' to 'int' error in List

From Dev

C++ cannot convert argument 1 from 'int**' to 'const int **'

From Dev

C++ cannot convert argument 1 from 'int**' to 'const int **'

From Dev

C# winforms Argument 1: cannot convert from 'string' to 'int'

From Dev

Cannot convert 'int*' to 'int* (*)[9]' for argument '1'

From Dev

C++ --- error C2664: 'int scanf(const char *,...)' : cannot convert argument 1 from 'int' to 'const char *'

From Dev

Compilation error: cannot convert argument 1 from 'student[20]' to 'student'

From Dev

Cannot convert from Object to Int

From Dev

.cpp:23: error: cannot convert ‘std::string’ to ‘const char*’ for argument ‘1’ to ‘int atoi(const char*)’

From Dev

c++ cannot convert 'double' to 'double*' for argument 1 to 'void sort(double*,int)' error

From Dev

Cannot convert argument 1 from '*' to "std::string'

From Dev

error C2664: 'print_result' : cannot convert parameter 1 from 'int (__cdecl *)(int,int,int)' to 'int'

From Dev

Error 'cannot convert value of type 'int' to expected argument type 'UInt'

From Dev

error C2440: 'default argument': cannot convert from 'const wchar_t [1]' to 'BSTR'

From Dev

"cannot convert argument 1 from 'Node<T>' to 'std::nullptr_t" compiler error

From Dev

How do I fix the error: Argument 1: cannot convert from 'string' to 'Name.Entity.Models.MakeModelInfo

From Dev

Error CS1503 Argument 1: cannot convert from 'string[]' to 'string' for folders found

From Dev

Error Cannot convert from int to boolean

From Dev

cannot convert from 'AnonymousType#1' to 'int'

From Dev

cannot convert from 'AnonymousType#1' to 'int'

From Dev

decltype error C2440 cannot convert from 'int *' to 'int *&'

From Dev

Weird compiler error: Cannot convert parameter from 'int' to 'int &&'

From Dev

error C2440: '=' : cannot convert from 'int *' to 'int **'

From Dev

error C2440: '=' : cannot convert from 'int *' to 'int **'

From Dev

Cannot convert argument 1 from 'const char [5]' to 'LPCTSTR'

From Dev

Cannot convert argument 1 from 'const char [11]' to 'LPCWSTR'

From Dev

Cannot implicitly convert type object to int error combobox

Related Related

  1. 1

    cannot convert argument 1 from int to int && error

  2. 2

    cannot convert argument 1 from int to int && error

  3. 3

    Argument1: cannot convert from 'string' to 'int' error in List

  4. 4

    C++ cannot convert argument 1 from 'int**' to 'const int **'

  5. 5

    C++ cannot convert argument 1 from 'int**' to 'const int **'

  6. 6

    C# winforms Argument 1: cannot convert from 'string' to 'int'

  7. 7

    Cannot convert 'int*' to 'int* (*)[9]' for argument '1'

  8. 8

    C++ --- error C2664: 'int scanf(const char *,...)' : cannot convert argument 1 from 'int' to 'const char *'

  9. 9

    Compilation error: cannot convert argument 1 from 'student[20]' to 'student'

  10. 10

    Cannot convert from Object to Int

  11. 11

    .cpp:23: error: cannot convert ‘std::string’ to ‘const char*’ for argument ‘1’ to ‘int atoi(const char*)’

  12. 12

    c++ cannot convert 'double' to 'double*' for argument 1 to 'void sort(double*,int)' error

  13. 13

    Cannot convert argument 1 from '*' to "std::string'

  14. 14

    error C2664: 'print_result' : cannot convert parameter 1 from 'int (__cdecl *)(int,int,int)' to 'int'

  15. 15

    Error 'cannot convert value of type 'int' to expected argument type 'UInt'

  16. 16

    error C2440: 'default argument': cannot convert from 'const wchar_t [1]' to 'BSTR'

  17. 17

    "cannot convert argument 1 from 'Node<T>' to 'std::nullptr_t" compiler error

  18. 18

    How do I fix the error: Argument 1: cannot convert from 'string' to 'Name.Entity.Models.MakeModelInfo

  19. 19

    Error CS1503 Argument 1: cannot convert from 'string[]' to 'string' for folders found

  20. 20

    Error Cannot convert from int to boolean

  21. 21

    cannot convert from 'AnonymousType#1' to 'int'

  22. 22

    cannot convert from 'AnonymousType#1' to 'int'

  23. 23

    decltype error C2440 cannot convert from 'int *' to 'int *&'

  24. 24

    Weird compiler error: Cannot convert parameter from 'int' to 'int &&'

  25. 25

    error C2440: '=' : cannot convert from 'int *' to 'int **'

  26. 26

    error C2440: '=' : cannot convert from 'int *' to 'int **'

  27. 27

    Cannot convert argument 1 from 'const char [5]' to 'LPCTSTR'

  28. 28

    Cannot convert argument 1 from 'const char [11]' to 'LPCWSTR'

  29. 29

    Cannot implicitly convert type object to int error combobox

HotTag

Archive