Solved

How to add characters or strings to a string?

Posted on 2004-08-23
2
192 Views
Last Modified: 2010-04-15
string text = "";
string add = "badger";

I want some function so that 'text' would equal to "badgerbadgerbadgerbadger..." and so on. The 'add' would be inserted into 'text' a specified amount of times.

I have tried the 'Insert()' function, but it does not seem to work. Thanks!

0
Comment
Question by:krupini
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 22

Accepted Solution

by:
cookre earned 80 total points
ID: 11877409
for (i=0; i<n; i++) text=text+add;
0
 
LVL 3

Expert Comment

by:gillgates
ID: 11877435
string add(string stringtoadd, int numberofadds)
{
    string temp = "";

    for(int i = 0; i<numberofadds; i++)
    {
          temp += stringtoadd;
    }
   
    return temp;
}        
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Get distinct values from excel or comm seperated file 4 40
Sort GridView by ID Descending 1 24
jquery + C#.net radiobuttonlist 3 45
Selenium and Xpath 4 30
Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

756 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question