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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T00:06:57+00:00 2026-06-08T00:06:57+00:00

Lets assume we have two string arrays string[] array1 = {aa, bb, cc}; string[]

  • 0

Lets assume we have two string arrays

string[] array1 = {"aa", "bb", "cc"};
string[] array2 = {"bb", "aa", "cc", "bb", "aa", "cc"};

now the string bb in array2 is in second position of array1 so the output should be 2

aa in array2 is in first position of array1 so the output should be 1

cc in array2 is in third position of array1 so the output should be 3

bb in array2 is in second position of array1 so the output should be 2

so on..

all these output index positions should be stored in an array..

any idea how to accomplish this in C#.net?

  • 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-08T00:06:58+00:00Added an answer on June 8, 2026 at 12:06 am

    Something like this:

    int[] indicies = array2.Select(n => Array.IndexOf(array1, n)).ToArray();
    

    This will project the elements of array2 as a sequence of their indicies in array1, and convert the result to an array.


    As pointed out in the comments, the original requirement was that “aa” map to the value 1, even though its index in array1 is 0. Offsetting the computed index by 1 will fix this:

    int[] indicies = array2.Select(n => Array.IndexOf(array1, n) + 1).ToArray();
    

    With this modification an element not found in array1 will result in an index of 0 instead of -1, of course.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a city table that has two columns from_city to_city now lets assume
Lets assume I have two hashes. One of them contains a set of data
Let's assume we have two arrays of the same size - A and B
lets assume that we have two operation contracts defined on wcf service, sync and
lets assume we have this table called visits and it has two fields id
Let's assume I have two gmdistibution models that i obtained using modeldata1=gmdistribution.fit(data1,1); modeldata2=gmdistribution.fit(data2,1); Now
Let's say we have two objects. Furthermore, let's assume that they really have no
Lets assume I have several <span class='remove-type'> elements on a page. In jQuery document.ready
Lets assume I have 2 XML variables in SQL Server 2008 with the following
Lets assume I have the following 3 entities: Customer,Order,Product which interact in the View

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.