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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T08:44:59+00:00 2026-06-10T08:44:59+00:00

I am trying to author an extension method for a string that takes one

  • 0

I am trying to author an extension method for a string that takes one argument and it appends the argument to the string’s value. Here is the behavior I want:

    public static void AddNumber(this string originalValue, string id)
    {
        List<string> ids = originalValue.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries).ToString();
        ids.Add(id);
        string newValue = string.Join(",", ids);
        originalValue = newValue;
    }

Then I would like to use this as follows:

        string testing = "";
        testing.AddNumber("1"); // value should be 1
        testing.AddNumber("2"); // value should be 1,2
        testing.AddNumber("3"); // value should be 1,2,3

The issue is that I am seeing this:

        string testing = "";
        testing.AddNumber("1"); // value is ""
        testing.AddNumber("2"); // value is ""
        testing.AddNumber("3"); // value is ""

Now I have read the this! issue here on StackOverflow, and I am aware that I am doing a similar thing. I can’t replace the entire value of the string, I have to modify the contents of the string that is sent through… I just can’t find a way to modify it. I’ve tried modifying the character array and have had no luck. Any ideas?

  • 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-10T08:45:01+00:00Added an answer on June 10, 2026 at 8:45 am

    Strings are immutable.
    That’s fundamentally impossible.

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

Sidebar

Related Questions

I'm trying to implement the example outlined here: http://www.codeproject.com/Articles/30994/Introduction-to-WPF-Templates The author states The ContentPresenter
I'm trying to write a DSL that allows me to do Policy.name do author
I'm trying to build a bookmarklet that will get the current page/article's author and
I am trying to return the description value of the corresponding author name and
I am trying to get users that are either administrator, editor or author as
The author of a web-service that I am trying to connect to, tells me
I'm trying to display some content based on a post author in Wordpress. Here
Trying to write a regex that can split title and author given the syntax:
I am trying to count author's post count in a month. So, I don't
I am trying to find an author in a set, and i am having

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.