Id and its Details
-
First time to pose a question on this board...fairly new to C# too, so please go easy :-D I want to do something like this in Generics:
List myList = new List();
This blows up obviously...any workarounds? Thanks! Mikeyyy
-
First time to pose a question on this board...fairly new to C# too, so please go easy :-D I want to do something like this in Generics:
List myList = new List();
This blows up obviously...any workarounds? Thanks! Mikeyyy
Thats because it's expecting
T
which is the type of element in the list. If your creating a list of strings then you should declare it asList<string> myList = new List<string>();
-
Ignore my other reply, I assumed you didn't pass the type of element, the html formatting actually removed it. The list can have only one type, so it would be
List<string> myList = new List<string>(); or List<int> myList = new List<int>();
If your are looking at having a KeyedList then have a look at this article[^] -
If you are trying to store two items for each element in the list then you should be creating a class.
class DtoListItem
{
public int SomeInt;
public string[] SomeStringArray;
}// In some method somewhere...
List<DtoListItem> myList = new List<DtoListItem>();
Upcoming events: * Glasgow: SQL Server 2005 - XML and XML Query Plans, Mock Objects, SQL Server Reporting Services... Never write for other people. Write for yourself, because you have a passion for it. -- Marc Clifton My website
-
First time to pose a question on this board...fairly new to C# too, so please go easy :-D I want to do something like this in Generics:
List myList = new List();
This blows up obviously...any workarounds? Thanks! Mikeyyy