.net - What would be the Linq code for this grouping using VB.NET 2008? -


I have a population of 0 to 119 years.

I want to connect this population to the group according to the following concept age of 15 to 49 years:

  1. 15 to 19;
  2. 20 to 24;
  3. 25 to 29;
  4. 35 to 39;
  5. 40 to 44;
  6. 45 to 49.

    Apart from any age, they are useless to calculate, I need to demonstrate. Here are some sample data and codes.

    I have an annual population group that represents the demographic population for each year.

      Integer public class as public year Annual Population public id as integer public gender as String Public EarFage Double (?) = New double? (119) {} and class   

    Then, the number of people in the Oreg Orange / collection property of the year includes their gender example:

      Population Year = 200 9 yearly population. = = Annual increase = age for gender = "F" c age. Year interval Long - 1 step 1 year (age) = 42356.67f 'Of course, this number varies from one year to another! Next I would like the group as follows:   Dual group (double) = Double double (6) {} Integer for age As per = 15 to 49 phase 1 dim index integer = 0 case case case 15 to 19 index = 0 case 20 to 24 index = 1 case 25 to 29 index = 2 case 30 to 34 index = 3 case 35 to 39 index = 4 Case 40 to 44 Index = 5 Case 45 to 49 Index = 6 Select Asset Group (Index) + = Annual Population. , I will be the sum of the population for each category of age group    

    So, although I want to group them, and then to group them I have no general No key, no luck! = C in P #, I think this is what I want:

      double [] groups = new double [7]; (Age, number) = (group) (age% 4)] = = annual population. Year interval [age 1]. Benefits? Annual population Years of age [age - 1] Value: 0.0;});   

    I do not seem to be able to get into VB.NET 2008, if I try to go with new action (T1, T2) or Other function (double key ?, vaccine) . I am not comfortable with all of these! = (( Underlying question: Why is it so complicated in VB.NET to work with Lambadas ?! )

    My code really works, I only have a good Perhaps I'm looking for a more readable solution, although it's easy to understand what I'm trying to achieve here.

    Still, does anyone have a clue about how to

    thanks! =)

    Your list using statements; The key will be 0 to 6, respectively. After this, you can only use the Sum operator on each group.

    In C #, this looks like this (you do not have case S in C):

      var filtered = data Where (item => items.ge> 15 & amp; amp; Item.Age & lt; = 49) .GroupBy (item = & gt; {if (item.Age & gt; 15 & amp; amp; ; Item.Age & lt; = 1) Returns 0; Otherwise, if (item.exe = 24) return 1; otherwise if (item.ge  = 39) returns 4; And if (item.Ege and LT; = 44) returns 5; And if (item, edge & lt; = 49) Return 6;}); After that, you can create a dictionary:  
      var dict = filtered.ToDictionary (i = & gt; i.Key, i = & gt; / * do something with the sequence * / );    

Comments