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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T02:57:53+00:00 2026-05-24T02:57:53+00:00

If i have two arrays First: A, B, C Second: ?, B, C I

  • 0

If i have two arrays

   First: A, B, C
   Second: ?, B, C

I want to compare only items from Second with items from First which is does not contains question mark “?”.

So for such case:

   First: A, B, C
   Second: ?, B, C

I wan to compare just items 1 and 2 because item 0 in the Second array contains ?.

For that one:

   First: A, B, C
   Second: 2, ?, C

I want to compare only items 0 and 2 because item 1 in Second array contains ?

Any ideas how better and with minimum amount of code to do that? If it would required to create any lists or any another collections that is fine.

  • 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-05-24T02:57:54+00:00Added an answer on May 24, 2026 at 2:57 am

    Using LINQ from the comfort of your armchair:

    // Input data:
    var first = new[] { "A", "B", "?" };
    var second = new[] { "?", "B", "C" };
    
    // This actually filters out pairs where either first or second
    // is equal to "?". If you only want to filter out pairs where the
    // second is "?", adjust accordingly.
    var toCompare = first.Zip(second, Tuple.Create)
                         .Where(t => t.Item1 != "?" && t.Item2 != "?");
    
    // And now you have a collection of Tuple<string, string>, which
    // can be processed in a multitude of ways:
    Console.Out.WriteLine(string.Format(
        "Compared {0} items, and found {1} of them equal.",
        toCompare.Count(),
        toCompare.All(t => t.Item1 == t.Item2) ? "all" : "not all"));            
    

    Update:

    If the comparison predicate (the method that compares a pair of items and returns a boolean) is going to be more complicated than the above, it makes sense to define it either as a lambda (if it’s not going to be reused and it’s short enough) or as a proper method otherwise.

    For example, to implement what’s mentioned in a comment below:

    Func<Tuple<string, string>, bool> predicate = t =>
        t.Item2 == "?" ||
        t.Item2 == "_" && t.Item1 != string.Empty ||
        t.Item2 == t.Item1;
    
    // And now you have a collection of Tuple<string, string>, which
    // can be processed in a multitude of ways:
    Console.Out.WriteLine(string.Format(
        "Compared {0} items, and found {1} of them equal.",
        toCompare.Count(),
        toCompare.All(predicate) ? "all" : "not all"));            
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two arrays of System.Data.DataRow objects which I want to compare. The rows
I have two arrays built while parsing a text file. The first contains the
I have two arrays which contain objects of assets, now I want to subtract
So basically I have these two arrays I want to merge... array(1) { [first]=>
I have two integer arrays which contain numeric values. I want to look through
i want two arrays first one of all subjects and the second of all
The setup: I have two arrays which are not sorted and are not of
I have two arrays which contain times. The first is the state of a
I have two arrays in PHP. The first array ($author_array) is comprised of user_ids
I have two arrays. One contains id=>count and the other contains id=>name . I'm

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.