How to make generic List
class myClass
{
string _dataType;
public List
if (dataType=="bool")
_list=new List
else if (dataType=="int16")
_list=new List
else if (dataType == "string")
_list=new List
else
_list = new List
Error: Cannot implicitly convert type 'System.Collections.Generic.List
SokakPosted Mar 28, 2007, 10:18 PM
Eg:
public class myClass
{
private List
// Implement your code here using "T" as your type where needed rather than worrying about hard-coded types.
}
You can also restrict the types that your class supports.
Eg: To restrict it to Int, Bool, or String
public class myClass
Mike GoldPosted Mar 26, 2007, 2:58 PM
best
-Mike