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

  • SEARCH
  • Home
  • 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 8325057
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T00:18:16+00:00 2026-06-09T00:18:16+00:00

Basically I’m looking to select both string columns and put it all into a

  • 0

Basically I’m looking to select both string columns and put it all into a single array of strings. Right now I’m having to do two selects and combine the results. It isn’t a huge deal, I just think it looks awkward. Any suggestions on how to accomplish the same goal with one linq statement? Here is a test case I’m using to mess around:

[TestFixture]
  public class test {

    public class Values {
      public string Present { get; set; }
      public string Previous { get; set; }
      public bool Flag { get; set; }
    }

    [Test]
    public void test1() {

      var list = new List<Values> {
        new Values { Present = "present1", Previous = "previous1", Flag = false },
        new Values { Present = "present2", Previous = "previous2", Flag = false },
        new Values { Present = "present3", Previous = "previous3", Flag = true },
        new Values { Present = "present4", Previous = "previous4", Flag = true }
      };


      var r1 = list.Where(c => c.Flag).Select(c => c.Present);
      var r2 = list.Where(c => c.Flag).Select(c => c.Previous);
      var combined = r1.Concat(r2);

      Assert.AreEqual(4, combined.Count());
    }
  }
  • 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-09T00:18:17+00:00Added an answer on June 9, 2026 at 12:18 am

    An alternative solution with using SelectMany (it keeps the duplicates):

    var combined = list.Where(c => c.Flag)
                       .SelectMany(c => new[] { c.Present, c.Previous });
    Assert.AreEqual(4, combined.Count());
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basically I have converted a tab delimited txt file into a list containing a
Basically my question is, if I have a number string, and i'm going to
Basically I have a single element inside of an xml file where I store
Basically, I'm just looking for pointers here. Ideally, I'd just supply a GPS coordinate
Basically I have two models: User and Godfather. The godfather table has three columns:
Basically, I've seen this used all to often: public event MyEventHandler MyEvent; private void
Basically i've a table for my users (it's nightclub website) and now i'm trying
Basically, something better than this: <input type=file name=myfile size=50> First of all, the browse
Basically, I'm trying to tap into the Soap pipeline in .NET 2.0 - I
Basically I have a navbar and a title, that both have the properties, position:

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.