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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T14:36:34+00:00 2026-06-06T14:36:34+00:00

I am trying to create a program which will substitute a character in place

  • 0

I am trying to create a program which will substitute a character in place of another. I have created two arrays, odd and even as follows:

char[] odd = { 'a', 'c', 'e', 'g', 'i', 'k', 'm', 'o', 'q', 's', 'u', 'w', 'y' };
char[] even ={ 'b', 'd', 'f', 'h', 'j', 'l', 'n', 'p', 'r', 't', 'v', 'x', 'z' };

Now, if the input is ‘a’, it has to put ‘b’ and if the input is ‘b’, it has to print ‘a’.

So i thought it is best to match the index of both the arrays since they have equal count. the basic idea is this :

the input is ‘a’, so the compiler takes the index of ‘a’ – 0 into account and substitutes the value at even with the index 0 – ‘b’.

so I thought of assigning a spare character ‘j’, which will find the index of the input and outputs the corresponding character from the array – even[].

I tried few times but could not get a solution. Kindly help me in this…

This is what I have tried.

The desired input maybe like this : Hello
The desired output should be this: Gfkkp

This supposedly gives me the desired result.

private void superSecretFormula(string myName)  
{
    string read = myName;
    int count = read.Length;

    char[] odd = { 'a', 'c', 'e', 'g', 'i', 'k', 'm', 'o', 'q', 's', 'u', 'w', 'y' };
    //char[] j;

    char[] even = { 'b', 'd', 'f', 'h', 'j', 'l', 'n', 'p', 'r', 't', 'v', 'x', 'z' };
    for (int i = 0; i < count; i++)
    {
        for (int j = 0; j < 13 ; j++)
        {
            if (read[i]==odd[j])
            {
                int k = j;
                textBlock1.Text = textBlock1.Text + Convert.ToString(char.ToUpperInvariant(even[k]));
            }
            if (read[i] == even[j])
            {
                int k = j;
                textBlock1.Text = textBlock1.Text + Convert.ToString(char.ToUpperInvariant(odd[k]));
            }
        }
    }
}

Kindly comment on the quality and approach in solving this problem, as I am a newbie and I am starting to learn code only now. Thanks

  • 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-06T14:36:35+00:00Added an answer on June 6, 2026 at 2:36 pm

    Assuming all your substitutions are unique I would consider changing your structure to something like this to ease the usage.

    class Program
    {
        static void Main(string[] args)
        {
            var subs = new Substitutes {{'a', 'b'}, {'c', 'd'}};
    
            Console.WriteLine(subs['a']); //Prints b
            Console.WriteLine(subs['b']); //Prints a
        }
    
        class Substitutes : Dictionary<char, char>
        {
             public new void Add(char item, char substitute)
             {
                 base.Add(item, substitute);
                 base.Add(substitute, item);
             }
        }
    }
    

    Now substituting all chars in a string would be trivial by just checking if the key exists.

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

Sidebar

Related Questions

I have been trying to create a simple program with Python which uses OpenCV
I am trying to create a program which will show me the status of
Iam trying to create a java program in which, i will be able to
I am trying to create a program which will read a file and check
I'm trying to create a program for Android which will read in text, and
I'm trying to create a program which will visualize different sorting algorithms by drawing
Hey all I was trying to create a java program which will remain logged
I am trying to create a soundboard program which will play sounds using the
I'm trying to make a program which will create a sum of directories the
I'm trying to use this example to create a program which will list all

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.