C#C
C#7mo ago
stigzler

✅ Cannot convert List<MyClass> to List<object>

I'm trying to design a custom generic collection editor in Winforms. I'm getting into a bit of a mess with casting the received class type onto a list of objects. I'm not very good with generics, so tried this via List<object>. See my code here:

https://pastebin.com/M2DwziWj

Gives me the attached error (precis: Unable to cast object of type List<SupportApplications> to type List<object>

I'm sure this may be a job for List<T> or something, but I've never really got my head around generics. I know this is me getting some basic principles wrong. Can anyone help with example code?
image.png
Pastebin
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
Was this page helpful?