How to handle type “Object {System.Collections.Generic.List<object>}”

DxHito

This is my first time encountering with such an object.

>Link of image of my local window during debug<

So to put it very simply, how do I access the value for CardNO or ItemID, which is 296 and 130 respectively when the only methods 'test' give are exactly like a normal object and I don't know what to cast it to. I can't even do this 'test[0]'.

This is where 'test' comes from:

private void ListBoxIssue_OnDragEnter(object sender, DragEventArgs e)
    {
        var test = DragDropPayloadManager.GetDataFromObject(e.Data, typeof(CommsItem));
    }
Juan Lopes

Use

var item = (CommsItem)((List<object>)test).FirstOrDefault();

Be sure to check first if test is an instance of List<object> before casting, and if test[0] is an instance of CommsItem.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

No mapping exists from object type System.collections.Generic.List

From Dev

Cannot deserialize the current JSON object..into type 'System.Collections.Generic.List`1[System.String]'

From Dev

Unable to cast object of type 'Newtonsoft.Json.Linq.JArray' to type 'System.Collections.Generic.List`

From Dev

error "Unable to cast object of type 'System.Int32' to type 'System.Collections.Generic.List`1[System.Int32]'"

From Dev

Unable to cast object of type 'System.Collections.Generic.List`1[System.Decimal]' to type 'System.IConvertible'

From Dev

Unable to cast object of type 'System.Collections.Generic.List`1[System.Decimal]' to type 'System.IConvertible'

From Dev

Cannot deserialize the current JSON object (e.g. {"name":"value"}) into type 'System.Collections.Generic.List

From Dev

Cannot deserialize the current JSON object (e.g. {"name":"value"}) into type 'System.Collections.Generic.List`

From Dev

Cannot deserialize the current JSON object (e.g. {"name":"value"}) into type 'System.Collections.Generic.List

From Dev

Object not storing JSON data: Cannot deserialize the current JSON object (e.g. {"name":"value"}) into type 'System.Collections.Generic.List

From Dev

Unable to cast object of type 'System.Collections.ArrayList' to type 'System.Collections.Generic.IEnumerable'

From Dev

JSON.Net - cannot deserialize the current json object (e.g. {"name":"value"}) into type 'system.collections.generic.list`1

From Dev

Cannot deserialize the current JSON object (e.g. {"name":"value"}) into type 'System.Collections.Generic.List`1'

From Dev

Unable to cast object of type 'System.Collections.Generic.List`1 [<>f__AnonymousType6`65[System.String,System.Decimal,System.Nullable`1

From Dev

Converting JSON to Object fails - Cannot deserialize the current JSON object into System.Collections.Generic.List

From Dev

Powershell generic collections list not displaying multiple object

From Dev

How cast System.Data.Entity.Infrastructure.DbQuery type to System.Collections.Generic.List type?

From Dev

How cast System.Data.Entity.Infrastructure.DbQuery type to System.Collections.Generic.List type?

From Dev

Cannot implicitly convert type 'System.Collections.Generic.List<<anonymous type:>>' to 'System.Collections.Generic.List

From Dev

C# JSON error => Cannot deserialize JSON object into type 'System.Collections.Generic.IEnumerable`1

From Dev

List with in a List of System::Collections::Generic::List<T> type is possible?

From Dev

Cannot implicitly convert type System.Collections.Generic.List<> to System.Collections.Generic.List<>

From Dev

Cannot implicitly convert type 'System.Collections.Generic.List< >' to 'System.Collections.Generic.IList< >'

From Dev

Convert type 'System.Collections.Generic.List<string>' to 'System.Collections.Generic.IList<>'

From Dev

Cannot implicitly convert type 'System.Collections.Generic.List< >' to 'System.Collections.Generic.IList< >'

From Dev

Combine two EF Queries, Unable to cast object of type System.Data.Entity.Infrastructure.DbQuery to System.Collections.Generic.IEnumerable

From Dev

Scala Macros: How to get a Type object of a generic List

From Dev

Unable to cast object of type 'System.Collections.Generic.HashSet`1[libraryWebProject.Major]' to type 'libraryWebProject.Major'

From Dev

How to convert a class object to generic object type?

Related Related

  1. 1

    No mapping exists from object type System.collections.Generic.List

  2. 2

    Cannot deserialize the current JSON object..into type 'System.Collections.Generic.List`1[System.String]'

  3. 3

    Unable to cast object of type 'Newtonsoft.Json.Linq.JArray' to type 'System.Collections.Generic.List`

  4. 4

    error "Unable to cast object of type 'System.Int32' to type 'System.Collections.Generic.List`1[System.Int32]'"

  5. 5

    Unable to cast object of type 'System.Collections.Generic.List`1[System.Decimal]' to type 'System.IConvertible'

  6. 6

    Unable to cast object of type 'System.Collections.Generic.List`1[System.Decimal]' to type 'System.IConvertible'

  7. 7

    Cannot deserialize the current JSON object (e.g. {"name":"value"}) into type 'System.Collections.Generic.List

  8. 8

    Cannot deserialize the current JSON object (e.g. {"name":"value"}) into type 'System.Collections.Generic.List`

  9. 9

    Cannot deserialize the current JSON object (e.g. {"name":"value"}) into type 'System.Collections.Generic.List

  10. 10

    Object not storing JSON data: Cannot deserialize the current JSON object (e.g. {"name":"value"}) into type 'System.Collections.Generic.List

  11. 11

    Unable to cast object of type 'System.Collections.ArrayList' to type 'System.Collections.Generic.IEnumerable'

  12. 12

    JSON.Net - cannot deserialize the current json object (e.g. {"name":"value"}) into type 'system.collections.generic.list`1

  13. 13

    Cannot deserialize the current JSON object (e.g. {"name":"value"}) into type 'System.Collections.Generic.List`1'

  14. 14

    Unable to cast object of type 'System.Collections.Generic.List`1 [<>f__AnonymousType6`65[System.String,System.Decimal,System.Nullable`1

  15. 15

    Converting JSON to Object fails - Cannot deserialize the current JSON object into System.Collections.Generic.List

  16. 16

    Powershell generic collections list not displaying multiple object

  17. 17

    How cast System.Data.Entity.Infrastructure.DbQuery type to System.Collections.Generic.List type?

  18. 18

    How cast System.Data.Entity.Infrastructure.DbQuery type to System.Collections.Generic.List type?

  19. 19

    Cannot implicitly convert type 'System.Collections.Generic.List<<anonymous type:>>' to 'System.Collections.Generic.List

  20. 20

    C# JSON error => Cannot deserialize JSON object into type 'System.Collections.Generic.IEnumerable`1

  21. 21

    List with in a List of System::Collections::Generic::List<T> type is possible?

  22. 22

    Cannot implicitly convert type System.Collections.Generic.List<> to System.Collections.Generic.List<>

  23. 23

    Cannot implicitly convert type 'System.Collections.Generic.List< >' to 'System.Collections.Generic.IList< >'

  24. 24

    Convert type 'System.Collections.Generic.List<string>' to 'System.Collections.Generic.IList<>'

  25. 25

    Cannot implicitly convert type 'System.Collections.Generic.List< >' to 'System.Collections.Generic.IList< >'

  26. 26

    Combine two EF Queries, Unable to cast object of type System.Data.Entity.Infrastructure.DbQuery to System.Collections.Generic.IEnumerable

  27. 27

    Scala Macros: How to get a Type object of a generic List

  28. 28

    Unable to cast object of type 'System.Collections.Generic.HashSet`1[libraryWebProject.Major]' to type 'libraryWebProject.Major'

  29. 29

    How to convert a class object to generic object type?

HotTag

Archive