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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T03:50:36+00:00 2026-05-18T03:50:36+00:00

I have 2 strings, A and B. A contains HelloHowAreYou. B contains Bingo. I

  • 0

I have 2 strings, A and B. A contains “HelloHowAreYou”. B contains “Bingo”. I want to replace string A with string B resulting to “BingoHowAreYou”. Any tips on how to do this? Even a keyword is suffice.

I know this is kinda newbie, but i dont want to hunt all msdn doc just to find this simple things. As i said, a simple guide/keyword pointing to the right direction is enough.

Edit:

Assuming i dont know the contents of the strings. can i just use the replace? Thanks for the fast reply.

  • 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-18T03:50:37+00:00Added an answer on May 18, 2026 at 3:50 am

    Fortunately, you don’t need to hunt down all of MSDN… just the String class.

    As others have said, String.Replace(string, string) is probably what you’re looking for:

    string a = "HelloHowAreYou";
    string b = "Bingo";
    string c = a.Replace("Hello", b); // Now the value of c is "BingoHowAreYou"
    

    Alternatively, if you’re trying to just replace the first characters of a with the same number of characters in b, something like this would do instead, using Substring and string concatenation:

    string c = b.Length >= a.Length ? b : b + a.Substring(b.Length);
    

    (Depending on exactly what you want to do when b is longer than a of course.)

    A few things worth knowing though:

    • This is a good example of library functionality – so you won’t find a C# keyword for it. While some C# keywords do interact with the library (e.g. using statements that know about the IDisposable type) most of the time, if you’re interested in something which sounds like a library feature, you should be looking in the library documentation rather than looking for a keyword.
    • Strings are immutable: String.Replace doesn’t change the existing string – it returns a new string with the appropriate result. Some other types follow the same pattern – in particular value types such as DateTime are typically immutable, so DateTime.AddDays doesn’t change the existing value, but returns a new value.
    • It’s worth getting used to looking through MSDN. You’re likely to do it a lot, so having a look through the string class now would be good practice.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a File that COntains Strings in This Format: ACHMU)][2:s,161,(ACH Payment Sys Menus
I have strange problem... My file strings.xml contains: <?xml version=1.0 encoding=utf-8?> <resources> <string name=building_name>My
I have strings which contains thousand separators, however no string-to-number function wants to consume
I have a struct which contains strings and pointer within. Is there any library
I have column that contains strings. The strings in that column look like this:
I have a field that contains strings such as 'Blah-OVER', 'Blah-OveR', etc. and want
I have a part of HTML source file that contains strings that I want
I have an array in javascript. This array has strings that contains commas (,).
I have a list which contains strings integers and floats. I want to convert
I have a column of data that contains strings, and I want to create

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.