van  tive

van tive

  • NA
  • 2
  • 0

How to make List work?

Mar 25 2007 12:03 AM

How to make generic List<T> for bool, Int16 , string  in the following code?

class myClass
{
string _dataType;
public List<Object> _list;
public myClass(string dataType)
 {
  _dataType=dataType;

 if (dataType=="bool")
    _list=new List<bool>();
 else if (dataType=="int16")
   _list=new List<Int16>();
 else if (dataType == "string")
   _list=new List<string>();
 else
   _list = new List<Object>();
 }
}

Error: Cannot implicitly convert type 'System.Collections.Generic.List<bool>' to 'System.Collections.Generic.List<object>'


Answers (2)