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 8794803
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T23:18:04+00:00 2026-06-13T23:18:04+00:00

I have an IEnumerable of type String with Default values and a fix order.

  • 0

I have an IEnumerable of type String with Default values and a fix order.
I have a List of type Module with values in a random order.
I want to have ONE list of unique objects of type Module.
What I get with the below code is:
ONE list of unique objects of type String.

Someone knows a trick around this?

static void Main(string[] args) {    

    List<Module> moduleList = new List<Module>() {
        new Module{ ModuleId = 1, ModuleType = "world"},
        new Module{ ModuleId = 2, ModuleType = "wayne"},
        new Module{ ModuleId = 3, ModuleType = "hallo"},
        new Module{ ModuleId = 4, ModuleType = "tes"},
        new Module{ ModuleId = 5, ModuleType = "mi"},
        new Module{ ModuleId = 6, ModuleType = "haha"},
        new Module{ ModuleId = 7, ModuleType = "pipi"},
        new Module{ ModuleId = 8, ModuleType = "bla"},  
    };

    // This result is fine that the list is unified and the predefined 
    // values order is not changed: bla, tes, mi 
    // BUT I need to return a query with Module objects

    var query = GetDefaultValues().Union(moduleList.Select(t => t.ModuleType));
}

private static IEnumerable<string> GetDefaultValues() {
    yield return "bla";
    yield return "tes";
    yield return "mi";
}

Do a new Module() in every lambda and copy the values is NO option for me.

UPDATE:

Desired output:

a list of Modules:

new Module{ ModuleId = 8, ModuleType = "bla"},
new Module{ ModuleId = 4, ModuleType = "tes"},
new Module{ ModuleId = 5, ModuleType = "mi"},

new Module{ ModuleId = 1, ModuleType = "world"},
new Module{ ModuleId = 2, ModuleType = "wayne"},
new Module{ ModuleId = 3, ModuleType = "hallo"},
new Module{ ModuleId = 6, ModuleType = "haha"},
new Module{ ModuleId = 7, ModuleType = "pipi"},
  • 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-13T23:18:04+00:00Added an answer on June 13, 2026 at 11:18 pm
    var query = GetDefaultValues()
                .Select(v => moduleList.Find(m => m.ModuleType == v))
                .Union(moduleList);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a dictionary of type Dictionary<string, IEnumerable<string>> and a list of string values.
If I have variable of type IEnumerable<List<string>> is there a LINQ statement or lambda
Suppose I have a given object of type IEnumerable<string> which is the return value
I have a function that returns the following type: IEnumerable<IGrouping<String, ExportTransaction>> In this function
I have this IEnumerable of type Question.. the class Question has the properties, Question(string)
I have an object of the type IEnumerable<KeyValuePair<T,U>> keyValueList , I am using var
If I have an IEnumerable where ClassA exposes an ID property of type long.
I have several methods that have a return type IEnumerable<T> . These methods are
I have a ViewModel that contains a Product type and an IEnumerable< Product >
I have a view model that contains a Product class type and an IEnumerable<

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.