![]() | |
![]() |
| | Thread Tools | Search this Thread | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
I am trying to declare a container and then add anonymous types to it. I want to end up with something I can use with LINQ, but the normal way to load a list doesn't work -- I don't know how to declare the target container. the syntax should be something like: var[] list = <??>; but I need to declare the container before I have a var. TYPE list = new TYPE(); // I don't know how to declare a list of anonymous? foreach (string nm in someList) { list.Add( new { Name = nm, Company = aComp }; } I need a new pattern for LINQ. |
#3
| |||
| |||
|
#4
| |||
| |||
|
#5
| |||
| |||
|
|
Sorry about posting to the wrong area. I didn't realize anonymous types weren't in the CLR. |
It's often not made terribly clear which things are|
I think I can get your first suggestion to work. Is it possible to declare a variable inside the lambda? I need something like: (x = string[] fields = x.Split(); new { name = fields[0], company = fields[1]; ) but I'm getting compiler errors. I appologize for taking up your time -- I clearly have a lot of reading to do before I've got this down. |

![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
| |