Walid

Walid

  • 1.7k
  • 28
  • 886

Issues with generic List<T>

Nov 18 2023 3:54 PM

I am kinda newbe to C#. and I am trying to understand the logic of generic and OOP stuff.

My app consists of 3 layers. UI, BLL DAL. And I am customizing a gridview columns based on my needs. All the customized columns are sharing the event when the user type something in the cell, I do db search for that text. In the customized datagridview class.

I am sending information as mentioned below and upon that I receive different results. I used datatable before .. it works as it should . but I wanna accomplish that with types objects as List<T>. here is the code..

I'll be happy if someone makes my lift easier .. I tryied to have a variable and assige to it different values (class name, list<class name>. list of .. didn't work .. is C# or the logic supports am trying to do without going back to datatable ..

am working on this thing .. ( it says Implicitly-typed variables must be initialized ).

var obj;

if (a = 1 ) var obj = Activator.CreateInstance(typeof(CareerFile1));
if (a = 2 ) var obj = Activator.CreateInstance(typeof(CareerFile2));
if (a = 3 ) var obj = Activator.CreateInstance(typeof(CareerFile3));


dbo_Bll aaa = new dbo_Bll();
-- the problem comes from here .. 
List<obj> Lst = aaa.Get_LookupItem<obj>(c1);

Answers (3)