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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T01:26:36+00:00 2026-05-22T01:26:36+00:00

Thanks for the help with my question about making an array of booleans into

  • 0

Thanks for the help with my question about making an array of booleans into a string. The code is now working good. Now I have another problem. Maybe somebody would like to try. I think I could come up with a solution but if so I’m 99 percent sure that it would be not so simple as the answers I have seen from people here.

What I have is the string “ABD” from my question here. I also have an array of integers. For example [0] = 2, [1] = 3 and [2] = 1. I would like to find a way to apply this to my string to reorder the string so that the string changes to BDA.

Can anyone think of a simple way to do this?

  • 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-22T01:26:37+00:00Added an answer on May 22, 2026 at 1:26 am

    If those integers are 1-based indices within the string (i.e. 2 = 2nd character), then you could do this:

    string s = "ABD";
    int[] oneBasedIndices = new [] { 2, 3, 1 };
    
    string result = String.Join(String.Empty, oneBasedIndices.Select(i => s[i-1]));
    

    NB: If you are using a version less than C# 4.0, you need to put a .ToArray() on the end of the select.

    What this is doing is going through your int[] and with each int element picking the character in the string at that position (well -1, as the first index in an array is 0, but your example starts at 1).

    Then, it has to do a String.Join() to turn that collection of characters back into a String.


    As an aside, I’d recommend downloading LINQPad (no connection) – then you can just paste that code in there as a C# Program, and at any point type variable.Dump(); (e.g. result.Dump(); at the end) and see what the value is at that point.

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

Sidebar

Related Questions

This question is related to another question of mine. Thanks to some help I
I have a show/hide toggle working well in multiple instances (thanks to help here
I'm making a visualization for a BST implementation (I posted another question about it
i have a question about this code. class Queue { Node first, last void
Have a question about calling one prototype function in another prototype function. for instance
Thanks to some help I received yesterday I've got some dynamic summing working on
Thanks for your help! I'd like to output all companyName entries that have uploads
This question is expanding on another I had gotten help with via Stackoverflow (
I have a question about PHP sessions. I use a session to keep a
Have a question about VBS: How can i start a new window (e.g. of

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.