Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8503669
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T01:49:06+00:00 2026-06-11T01:49:06+00:00

I don’t really understand LINQ. I every example I find is overly simplified to

  • 0

I don’t really understand LINQ. I every example I find is overly simplified to the point where I don’t know why you would even use LINQ for it, or too complicated that I need to already know how LINQ works in order to understand it.

So I’m wondering if and how you would use LINQ to this… In this example let’s say you have a list of player classes, and inside of each class there is a list of abilities. Each ability has a level requirement. How can you use LINQ to select all abilities that are at or below a certain level for a set of specific classes?

Giveen this data:

  • Class1
    • Ability1 – Level 1
    • Ability2 – Level 5
    • Ability3 – Level 9
  • Class2
    • Ability4 – Level 1
    • Ability5 – Level 2
    • Ability6 – Level 6
  • Class3
    • Ability7 – Level 2
    • Ability8 – Level 4
    • Ability9 – Level 6

I want a list of all abilities for Class1 & Class3 that are level 5 or below. The result should be { Ability1, Ability2, Ability7, Ability8 }.

public class Class1
{

  public class Ability
  {
    public string Name { get; set; }
    public int Level { get; set; }
  }

  public class PlayerClass
  {
    public string Name { get; set; }
    public List<Ability> Abilities { get; set; }
  }

  public List<PlayerClass> Classes { get; set; }

  public Class1()
  {
    PlayerClass oClass;

    Classes = new List<PlayerClass>();

    oClass = new PlayerClass();
    oClass.Name = "Class1";
    oClass.Abilities = new List<Ability>();
    oClass.Abilities.Add(new Ability() { Name = "Ability1", Level = 1 });
    oClass.Abilities.Add(new Ability() { Name = "Ability2", Level = 5 });
    oClass.Abilities.Add(new Ability() { Name = "Ability3", Level = 9 });
    Classes.Add(oClass);

    oClass = new PlayerClass();
    oClass.Name = "Class2";
    oClass.Abilities = new List<Ability>();
    oClass.Abilities.Add(new Ability() { Name = "Ability4", Level = 1 });
    oClass.Abilities.Add(new Ability() { Name = "Ability5", Level = 2 });
    oClass.Abilities.Add(new Ability() { Name = "Ability6", Level = 6 });
    Classes.Add(oClass);

    oClass = new PlayerClass();
    oClass.Name = "Class3";
    oClass.Abilities = new List<Ability>();
    oClass.Abilities.Add(new Ability() { Name = "Ability7", Level = 2 });
    oClass.Abilities.Add(new Ability() { Name = "Ability8", Level = 4 });
    oClass.Abilities.Add(new Ability() { Name = "Ability9", Level = 6 });
    Classes.Add(oClass);

    IEnumerable<Ability> Abilities = 
                   GetAbilitiesForClasses("Class1;Class3".Split(';'), 5);
    //Abilities should contain Ability1, Ability2, Ability7, Ability8
  }

  public IEnumerable<Ability> GetAbilitiesForClasses
       (string[] asClassNames, int iLevel)
  {
    // TODO: Use LINQ to return the abilities for the class names 
           //contained in asClassNames that are at or below level: iLevel
    return null;
  }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T01:49:08+00:00Added an answer on June 11, 2026 at 1:49 am
    public IEnumerable<Ability> GetAbilitiesForClasses(string[] asClassNames, int iLevel)
    {
        return Classes
               .Where(X => asClassNames.Contains(X.Name))
               .SelectMany(X => X.Abilities)
               .Where(X => X.Level <= iLevel)
               .ToList();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Don't really know how to formulate the title, but it should be pretty obvious
Don't know if this has been asked before, so point me to another question
Don't know if anyone can help me with this or if it's even possible.
Don't know why but I can't find a solution to this. I have 3
Don't know much about running a function on every item in an array, still
don't know if the title describes anything about what I'm trying to say but
don't know what happened in my jcrop selection. I think I pressed some keys
Don't know how to google for such, but is there a way to query
Don't know why but font is not displaying.Please help. CSS(in css folder): style.css: @font-face
I don't know why, but this code worked for me a month ago... maybe

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.