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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T09:15:11+00:00 2026-06-04T09:15:11+00:00

I have created a simple program that i want to replace some chars with

  • 0

I have created a simple program that i want to replace some chars with others in array of string.I have created an array of string that contains some words,i want to loop on each word and check on some chars if it contains,but when i tried to replace nothing happens
here is my code

            string x = "";
            x = "Script friends above about type=text/javascript>BBC.adverts.writeleaderboardtrue) all </script>friends,eating,khaled,khaled,khaled";
 char[] delimiterChars = { ' ', ',', '.', ':', '\t', ':', '$', '=', ';', '<', '>', '!', ';', ']', '[', '"',
                                    '/','=','-','?'};
 string[] words = x.Split(delimiterChars);
            for (int j = 0; j < words.Length; j++)
            {
                words[j] = words[j].ToLower();
            }
 for (int i = 0; i < words.Length; i++)
            {
                for (int j = 0; j < words[j].Length; j++)
                {

                    if (words[i][j]=='a'||words[i][j]=='e'||words[i][j]=='i'||words[i][j]=='o'||words[i][j]=='u'
                        ||words[i][j]=='h'||words[i][j]=='w'||words[i][j]=='y')
                    {
                        words[i].Replace(words[i][j],'0');
                    }
                    else if (words[i][j] == 'b' || words[i][j] == 'f' || words[i][j] == 'p' || words[i][j] == 'v')
                    {
                        words[i].Replace(words[i][j], '1');
                    }

                     else if (words[i][j] == 'c' || words[i][j] == 'g' || words[i][j] == 'j' || words[i][j] == 'k'
                    || words[i][j] == 'q' || words[i][j] == 's' || words[i][j] == 'x' || words[i][j] == 'z')
                {
                    char xx = words[i][j];
                    words[i].Replace(xx, '2');
                    Console.WriteLine(words[i]);
                }
                else if (words[i][j] == 'd' || words[i][j] == 't')
                {
                    words[i].Replace(words[i][j], '3');
                }
                else if (words[i][j] == 'l')
                {
                    words[i].Replace(words[i][j], '4');
                }
                else if (words[i][j] == 'm' || words[i][j] == 'n')
                {
                    words[i].Replace(words[i][j], '5');
                }
                else if (words[i][j] == 'r')
                {
                    words[i].Replace(words[i][j], '6');
                }



}
}
  • 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-04T09:15:12+00:00Added an answer on June 4, 2026 at 9:15 am

    You are forgetting that Strings are immutable.

    words[i].Replace(words[i][j], '1') returns a new String instange with the replaced values.

    You have to assign your reference back to the newly generated String object:

    words[i] = words[i].Replace(words[i][j], '1');
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i want to create a simple program that i have a array of strings
I have a simple program that creates a thread, loops twenty times and then
I am new to Repository concept and get some questions. I have created simple
I have created a simple CLR procedure that creates a Folder. The problem is
I want to create a simple program that will convert a pdf to a
I have created a program that prints results on command line. (It is server
I created a really simple Java program that creates a java.net.ServerSocket on an open
I have been trying to create a simple program with Python which uses OpenCV
Could someone help me on this, I have created simple web services using axis2
How to manually create Friendly URLs? (PHP) So I have created simple php file

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.